Merge branch 'main' into enh-port-edit-gcode-dlg

# Conflicts:
#	src/slic3r/GUI/OG_CustomCtrl.cpp
#	src/slic3r/GUI/OG_CustomCtrl.hpp
This commit is contained in:
Ocraftyone 2024-01-01 10:58:04 -05:00
commit f78d55eac5
No known key found for this signature in database
GPG key ID: 85836ED21AD4D125
265 changed files with 29219 additions and 7128 deletions

View file

@ -94,10 +94,7 @@ if (SLIC3R_GUI)
# wrong libs for opengl in the link line and it does not link to it by himself.
# libslic3r_gui will link to opengl anyway, so lets override wx
list(FILTER wxWidgets_LIBRARIES EXCLUDE REGEX OpenGL)
if (UNIX AND NOT APPLE)
list(APPEND wxWidgets_LIBRARIES X11 wayland-client wayland-egl EGL)
endif ()
# list(REMOVE_ITEM wxWidgets_LIBRARIES oleacc)
message(STATUS "wx libs: ${wxWidgets_LIBRARIES}")

View file

@ -5356,7 +5356,7 @@ bool CLI::setup(int argc, char **argv)
for (const t_optiondef_map::value_type &optdef : *options)
m_config.option(optdef.first, true);
//set_data_dir(m_config.opt_string("datadir"));
set_data_dir(m_config.opt_string("datadir"));
//FIXME Validating at this stage most likely does not make sense, as the config is not fully initialized yet.
if (!validity.empty()) {

View file

@ -42,7 +42,8 @@ using namespace nlohmann;
namespace Slic3r {
static const std::string VERSION_CHECK_URL = "https://api.github.com/repos/softfever/OrcaSlicer/releases/latest";
static const std::string VERSION_CHECK_URL_STABLE = "https://api.github.com/repos/softfever/OrcaSlicer/releases/latest";
static const std::string VERSION_CHECK_URL = "https://api.github.com/repos/softfever/OrcaSlicer/releases";
static const std::string MODELS_STR = "models";
const std::string AppConfig::SECTION_FILAMENTS = "filaments";
@ -240,6 +241,10 @@ void AppConfig::set_defaults()
set_bool("stealth_mode", false);
}
if(get("check_stable_update_only").empty()) {
set_bool("check_stable_update_only", false);
}
// Orca
if(get("show_splash_screen").empty()) {
set_bool("show_splash_screen", true);
@ -1253,10 +1258,10 @@ std::string AppConfig::config_path()
return path;
}
std::string AppConfig::version_check_url() const
std::string AppConfig::version_check_url(bool stable_only/* = false*/) const
{
auto from_settings = get("version_check_url");
return from_settings.empty() ? VERSION_CHECK_URL : from_settings;
return from_settings.empty() ? stable_only ? VERSION_CHECK_URL_STABLE : VERSION_CHECK_URL : from_settings;
}
bool AppConfig::exists()

View file

@ -247,7 +247,7 @@ public:
// 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;
std::string version_check_url(bool stable_only = false) const;
// Returns the original Slic3r version found in the ini file before it was overwritten
// by the current version

View file

@ -5,7 +5,6 @@
#include <stack>
#include <functional>
#include <unordered_set>
#include <sstream>
#include <queue>
#include <functional>
@ -19,6 +18,7 @@
#include "Geometry/VoronoiVisualUtils.hpp"
#include "Geometry/VoronoiUtilsCgal.hpp"
#include "../EdgeGrid.hpp"
#include "ankerl/unordered_dense.h"
#define SKELETAL_TRAPEZOIDATION_BEAD_SEARCH_MAX 1000 //A limit to how long it'll keep searching for adjacent beads. Increasing will re-use beadings more often (saving performance), but search longer for beading (costing performance).
@ -522,14 +522,14 @@ static bool has_missing_twin_edge(const SkeletalTrapezoidationGraph &graph)
return false;
}
inline static std::unordered_map<Point, Point, PointHash> try_to_fix_degenerated_voronoi_diagram_by_rotation(
inline static ankerl::unordered_dense::map<Point, Point, PointHash> try_to_fix_degenerated_voronoi_diagram_by_rotation(
Geometry::VoronoiDiagram &voronoi_diagram,
const Polygons &polys,
Polygons &polys_rotated,
std::vector<SkeletalTrapezoidation::Segment> &segments,
const double fix_angle)
{
std::unordered_map<Point, Point, PointHash> vertex_mapping;
ankerl::unordered_dense::map<Point, Point, PointHash> vertex_mapping;
for (Polygon &poly : polys_rotated)
poly.rotate(fix_angle);
@ -562,7 +562,7 @@ inline static std::unordered_map<Point, Point, PointHash> try_to_fix_degenerated
inline static void rotate_back_skeletal_trapezoidation_graph_after_fix(SkeletalTrapezoidationGraph &graph,
const double fix_angle,
const std::unordered_map<Point, Point, PointHash> &vertex_mapping)
const ankerl::unordered_dense::map<Point, Point, PointHash> &vertex_mapping)
{
for (STHalfEdgeNode &node : graph.nodes) {
// If a mapping exists between a rotated point and an original point, use this mapping. Otherwise, rotate a point in the opposite direction.
@ -623,7 +623,7 @@ void SkeletalTrapezoidation::constructFromPolygons(const Polygons& polys)
const bool is_voronoi_diagram_planar = Geometry::VoronoiUtilsCgal::is_voronoi_diagram_planar_angle(voronoi_diagram);
const double fix_angle = PI / 6;
std::unordered_map<Point, Point, PointHash> vertex_mapping;
ankerl::unordered_dense::map<Point, Point, PointHash> vertex_mapping;
// polys_copy is referenced through items stored in the std::vector segments.
Polygons polys_copy = polys;
if (has_missing_voronoi_vertex || !is_voronoi_diagram_planar) {
@ -751,7 +751,7 @@ process_voronoi_diagram:
void SkeletalTrapezoidation::separatePointyQuadEndNodes()
{
std::unordered_set<node_t*> visited_nodes;
ankerl::unordered_dense::set<node_t*> visited_nodes;
for (edge_t& edge : graph.edges)
{
if (edge.prev)
@ -2221,7 +2221,7 @@ void SkeletalTrapezoidation::addToolpathSegment(const ExtrusionJunction& from, c
void SkeletalTrapezoidation::connectJunctions(ptr_vector_t<LineJunctions>& edge_junctions)
{
std::unordered_set<edge_t*> unprocessed_quad_starts(graph.edges.size() * 5 / 2);
ankerl::unordered_dense::set<edge_t*> unprocessed_quad_starts(graph.edges.size() * 5 / 2);
for (edge_t& edge : graph.edges)
{
if (!edge.prev)
@ -2230,7 +2230,7 @@ void SkeletalTrapezoidation::connectJunctions(ptr_vector_t<LineJunctions>& edge_
}
}
std::unordered_set<edge_t*> passed_odd_edges;
ankerl::unordered_dense::set<edge_t*> passed_odd_edges;
while (!unprocessed_quad_starts.empty())
{

View file

@ -7,7 +7,7 @@
#include <boost/polygon/voronoi.hpp>
#include <memory> // smart pointers
#include <unordered_map>
#include <ankerl/unordered_dense.h>
#include <utility> // pair
#include "utils/HalfEdgeGraph.hpp"
@ -163,8 +163,8 @@ protected:
* mapping each voronoi VD edge to the corresponding halfedge HE edge
* In case the result segment is discretized, we map the VD edge to the *last* HE edge
*/
std::unordered_map<vd_t::edge_type*, edge_t*> vd_edge_to_he_edge;
std::unordered_map<vd_t::vertex_type*, node_t*> vd_node_to_he_node;
ankerl::unordered_dense::map<vd_t::edge_type*, edge_t*> vd_edge_to_he_edge;
ankerl::unordered_dense::map<vd_t::vertex_type*, node_t*> vd_node_to_he_node;
node_t& makeNode(vd_t::vertex_type& vd_node, Point p); //!< Get the node which the VD node maps to, or create a new mapping if there wasn't any yet.
/*!

View file

@ -2,7 +2,8 @@
//CuraEngine is released under the terms of the AGPLv3 or higher.
#include "SkeletalTrapezoidationGraph.hpp"
#include <unordered_map>
#include <ankerl/unordered_dense.h>
#include <boost/log/trivial.hpp>
@ -180,8 +181,8 @@ bool STHalfEdgeNode::isLocalMaximum(bool strict) const
void SkeletalTrapezoidationGraph::collapseSmallEdges(coord_t snap_dist)
{
std::unordered_map<edge_t*, std::list<edge_t>::iterator> edge_locator;
std::unordered_map<node_t*, std::list<node_t>::iterator> node_locator;
ankerl::unordered_dense::map<edge_t*, std::list<edge_t>::iterator> edge_locator;
ankerl::unordered_dense::map<node_t*, std::list<node_t>::iterator> node_locator;
for (auto edge_it = edges.begin(); edge_it != edges.end(); ++edge_it)
{

View file

@ -782,10 +782,9 @@ bool WallToolPaths::removeEmptyToolPaths(std::vector<VariableWidthLines> &toolpa
*
* \param outer_to_inner Whether the wall polygons with a lower inset_idx should go before those with a higher one.
*/
std::unordered_set<std::pair<const ExtrusionLine *, const ExtrusionLine *>, boost::hash<std::pair<const ExtrusionLine *, const ExtrusionLine *>>> WallToolPaths::getRegionOrder(const std::vector<ExtrusionLine *> &input, const bool outer_to_inner)
WallToolPaths::ExtrusionLineSet WallToolPaths::getRegionOrder(const std::vector<ExtrusionLine *> &input, const bool outer_to_inner)
{
std::unordered_set<std::pair<const ExtrusionLine *, const ExtrusionLine *>, boost::hash<std::pair<const ExtrusionLine *, const ExtrusionLine *>>> order_requirements;
ExtrusionLineSet order_requirements;
// We build a grid where we map toolpath vertex locations to toolpaths,
// so that we can easily find which two toolpaths are next to each other,
// which is the requirement for there to be an order constraint.

View file

@ -5,7 +5,7 @@
#define CURAENGINE_WALLTOOLPATHS_H
#include <memory>
#include <unordered_set>
#include <ankerl/unordered_dense.h>
#include "BeadingStrategy/BeadingStrategyFactory.hpp"
#include "utils/ExtrusionLine.hpp"
@ -86,6 +86,8 @@ public:
*/
static bool removeEmptyToolPaths(std::vector<VariableWidthLines> &toolpaths);
using ExtrusionLineSet = ankerl::unordered_dense::set<std::pair<const ExtrusionLine *, const ExtrusionLine *>, boost::hash<std::pair<const ExtrusionLine *, const ExtrusionLine *>>>;
/*!
* Get the order constraints of the insets when printing walls per region / hole.
* Each returned pair consists of adjacent wall lines where the left has an inset_idx one lower than the right.
@ -94,7 +96,7 @@ public:
*
* \param outer_to_inner Whether the wall polygons with a lower inset_idx should go before those with a higher one.
*/
static std::unordered_set<std::pair<const ExtrusionLine *, const ExtrusionLine *>, boost::hash<std::pair<const ExtrusionLine *, const ExtrusionLine *>>> getRegionOrder(const std::vector<ExtrusionLine *> &input, bool outer_to_inner);
static ExtrusionLineSet getRegionOrder(const std::vector<ExtrusionLine *> &input, bool outer_to_inner);
protected:
/*!

View file

@ -119,8 +119,7 @@ void ExtrusionLine::simplify(const int64_t smallest_line_segment_squared, const
//h^2 = (L / b)^2 [square it]
//h^2 = L^2 / b^2 [factor the divisor]
const auto height_2 = int64_t(double(area_removed_so_far) * double(area_removed_so_far) / double(base_length_2));
coord_t weighted_average_width;
const int64_t extrusion_area_error = calculateExtrusionAreaDeviationError(previous, current, next, weighted_average_width);
const int64_t extrusion_area_error = calculateExtrusionAreaDeviationError(previous, current, next);
if ((height_2 <= scaled<coord_t>(0.001) //Almost exactly colinear (barring rounding errors).
&& Line::distance_to_infinite(current.p, previous.p, next.p) <= scaled<double>(0.001)) // Make sure that height_2 is not small because of cancellation of positive and negative areas
// We shouldn't remove middle junctions of colinear segments if the area changed for the C-P segment is exceeding the maximum allowed
@ -200,8 +199,7 @@ void ExtrusionLine::simplify(const int64_t smallest_line_segment_squared, const
junctions = new_junctions;
}
int64_t ExtrusionLine::calculateExtrusionAreaDeviationError(ExtrusionJunction A, ExtrusionJunction B, ExtrusionJunction C, coord_t& weighted_average_width)
{
int64_t ExtrusionLine::calculateExtrusionAreaDeviationError(ExtrusionJunction A, ExtrusionJunction B, ExtrusionJunction C) {
/*
* A B C A C
* --------------- **************
@ -219,27 +217,19 @@ int64_t ExtrusionLine::calculateExtrusionAreaDeviationError(ExtrusionJunction A,
* weighted-average width for the entire extrusion line.
*
* */
const int64_t ab_length = (B - A).cast<int64_t>().norm();
const int64_t bc_length = (C - B).cast<int64_t>().norm();
const coord_t width_diff = std::max(std::abs(B.w - A.w), std::abs(C.w - B.w));
if (width_diff > 1)
{
const int64_t ab_length = (B.p - A.p).cast<int64_t>().norm();
const int64_t bc_length = (C.p - B.p).cast<int64_t>().norm();
if (const coord_t width_diff = std::max(std::abs(B.w - A.w), std::abs(C.w - B.w)); width_diff > 1) {
// Adjust the width only if there is a difference, or else the rounding errors may produce the wrong
// weighted average value.
const int64_t ab_weight = (A.w + B.w) / 2;
const int64_t bc_weight = (B.w + C.w) / 2;
assert(((ab_length * ab_weight + bc_length * bc_weight) / (C - A).cast<int64_t>().norm()) <= std::numeric_limits<coord_t>::max());
weighted_average_width = (ab_length * ab_weight + bc_length * bc_weight) / (C - A).cast<int64_t>().norm();
assert((int64_t(std::abs(ab_weight - weighted_average_width)) * ab_length + int64_t(std::abs(bc_weight - weighted_average_width)) * bc_length) <= double(std::numeric_limits<int64_t>::max()));
return std::abs(ab_weight - weighted_average_width) * ab_length + std::abs(bc_weight - weighted_average_width) * bc_length;
}
else
{
const int64_t ab_weight = (A.w + B.w) / 2;
const int64_t bc_weight = (B.w + C.w) / 2;
const int64_t weighted_average_width = (ab_length * ab_weight + bc_length * bc_weight) / (ab_length + bc_length);
const int64_t ac_length = (C.p - A.p).cast<int64_t>().norm();
return std::abs((ab_weight * ab_length + bc_weight * bc_length) - (weighted_average_width * ac_length));
} else {
// If the width difference is very small, then select the width of the segment that is longer
weighted_average_width = ab_length > bc_length ? A.w : B.w;
assert((int64_t(width_diff) * int64_t(bc_length)) <= std::numeric_limits<coord_t>::max());
assert((int64_t(width_diff) * int64_t(ab_length)) <= std::numeric_limits<coord_t>::max());
return ab_length > bc_length ? width_diff * bc_length : width_diff * ab_length;
return ab_length > bc_length ? int64_t(width_diff) * bc_length : int64_t(width_diff) * ab_length;
}
}

View file

@ -186,9 +186,8 @@ struct ExtrusionLine
* \param A Start point of the 3-point-straight line
* \param B Intermediate point of the 3-point-straight line
* \param C End point of the 3-point-straight line
* \param weighted_average_width The weighted average of the widths of the two colinear extrusion segments
* */
static int64_t calculateExtrusionAreaDeviationError(ExtrusionJunction A, ExtrusionJunction B, ExtrusionJunction C, coord_t& weighted_average_width);
static int64_t calculateExtrusionAreaDeviationError(ExtrusionJunction A, ExtrusionJunction B, ExtrusionJunction C);
bool is_contour() const;

View file

@ -1720,7 +1720,7 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
//BBS: version check
bool dont_load_config = !m_load_config;
if (m_bambuslicer_generator_version) {
Semver app_version = *(Semver::parse(SLIC3R_VERSION));
Semver app_version = *(Semver::parse(SoftFever_VERSION));
Semver file_version = *m_bambuslicer_generator_version;
if (file_version.maj() != app_version.maj())
dont_load_config = true;
@ -3638,7 +3638,7 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
}*/
} else if (m_curr_metadata_name == BBL_APPLICATION_TAG) {
// Generator application of the 3MF.
// SLIC3R_APP_KEY - SLIC3R_VERSION
// SLIC3R_APP_KEY - SoftFever_VERSION
if (boost::starts_with(m_curr_characters, "BambuStudio-")) {
m_is_bbl_3mf = true;
m_bambuslicer_generator_version = Semver::parse(m_curr_characters.substr(12));
@ -6380,7 +6380,7 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
metadata_item_map[BBL_CREATION_DATE_TAG] = date;
metadata_item_map[BBL_MODIFICATION_TAG] = date;
//SoftFever: write BambuStudio tag to keep it compatible
metadata_item_map[BBL_APPLICATION_TAG] = (boost::format("%1%-%2%") % "BambuStudio" % SLIC3R_VERSION).str();
metadata_item_map[BBL_APPLICATION_TAG] = (boost::format("%1%-%2%") % "BambuStudio" % SoftFever_VERSION).str();
}
metadata_item_map[BBS_3MF_VERSION] = std::to_string(VERSION_BBS_3MF);
@ -7197,7 +7197,7 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
{
const std::string& temp_path = model.get_backup_path();
std::string temp_file = temp_path + std::string("/") + "_temp_1.config";
config.save_to_json(temp_file, std::string("project_settings"), std::string("project"), std::string(SLIC3R_VERSION));
config.save_to_json(temp_file, std::string("project_settings"), std::string("project"), std::string(SoftFever_VERSION));
return _add_file_to_archive(archive, BBS_PROJECT_CONFIG_FILE, temp_file);
}
@ -7538,7 +7538,7 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
// save slice header for debug
stream << " <" << SLICE_HEADER_TAG << ">\n";
stream << " <" << SLICE_HEADER_ITEM_TAG << " " << KEY_ATTR << "=\"" << "X-BBL-Client-Type" << "\" " << VALUE_ATTR << "=\"" << "slicer" << "\"/>\n";
stream << " <" << SLICE_HEADER_ITEM_TAG << " " << KEY_ATTR << "=\"" << "X-BBL-Client-Version" << "\" " << VALUE_ATTR << "=\"" << convert_to_full_version(SLIC3R_VERSION) << "\"/>\n";
stream << " <" << SLICE_HEADER_ITEM_TAG << " " << KEY_ATTR << "=\"" << "X-BBL-Client-Version" << "\" " << VALUE_ATTR << "=\"" << convert_to_full_version(SoftFever_VERSION) << "\"/>\n";
stream << " </" << SLICE_HEADER_TAG << ">\n";
for (unsigned int i = 0; i < (unsigned int)plate_data_list.size(); ++i)

View file

@ -3077,7 +3077,8 @@ static bool custom_gcode_sets_temperature(const std::string &gcode, const int mc
void GCode::print_machine_envelope(GCodeOutputStream &file, Print &print)
{
const auto flavor = print.config().gcode_flavor.value;
if (flavor == gcfMarlinLegacy || flavor == gcfMarlinFirmware) {
if ((flavor == gcfMarlinLegacy || flavor == gcfMarlinFirmware || flavor == gcfRepRapFirmware) &&
print.config().emit_machine_limits_to_gcode.value == true) {
int factor = flavor == gcfRepRapFirmware ? 60 : 1; // RRF M203 and M566 are in mm/min
file.write_format("M201 X%d Y%d Z%d E%d\n",
int(print.config().machine_max_acceleration_x.values.front() + 0.5),
@ -3120,7 +3121,6 @@ void GCode::print_machine_envelope(GCodeOutputStream &file, Print &print)
print.config().machine_max_jerk_y.values.front() * factor,
print.config().machine_max_jerk_z.values.front() * factor,
print.config().machine_max_jerk_e.values.front() * factor);
}
}
@ -4515,6 +4515,58 @@ std::string GCode::extrude_loop(ExtrusionLoop loop, std::string description, dou
// extrude along the path
std::string gcode;
// Port of "wipe inside before extruding an external perimeter" feature from super slicer
if (m_config.wipe_before_external_loop.value && !paths.empty() && paths.front().size() > 1 && paths.back().size() > 1 && paths.front().role() == erExternalPerimeter) {
const bool is_full_loop_ccw = loop.polygon().is_counter_clockwise();
bool is_hole_loop = (loop.loop_role() & ExtrusionLoopRole::elrHole) != 0; // loop.make_counter_clockwise();
const double nozzle_diam = EXTRUDER_CONFIG(nozzle_diameter);
// note: previous & next are inverted to extrude "in the opposite direction, and we are "rewinding"
Point previous_point = paths.front().polyline.points[1];
Point current_point = paths.front().polyline.points.front();
Point next_point = paths.back().polyline.points.back();
// can happen if seam_gap is null
if (next_point == current_point) {
next_point = paths.back().polyline.points[paths.back().polyline.points.size() - 2];
}
Point a = next_point; // second point
Point b = previous_point; // second to last point
if ((is_hole_loop ? !is_full_loop_ccw : is_full_loop_ccw)) {
// swap points
std::swap(a, b);
}
double angle = current_point.ccw_angle(a, b) / 3;
// turn outwards if contour, turn inwwards if hole
if (is_hole_loop ? !is_full_loop_ccw : is_full_loop_ccw) angle *= -1;
Vec2d current_pos = current_point.cast<double>();
Vec2d next_pos = next_point.cast<double>();
Vec2d vec_dist = next_pos - current_pos;
double vec_norm = vec_dist.norm();
// Offset distance is the minimum between half the nozzle diameter or half the line width for the upcomming perimeter
// This is to mimimize potential instances where the de-retraction is performed on top of a neighbouring
// thin perimeter due to arachne reducing line width.
coordf_t dist = std::min(scaled(nozzle_diam) * 0.5, scaled(paths.front().width) * 0.5);
// FIXME Hiding the seams will not work nicely for very densely discretized contours!
Point pt = (current_pos + vec_dist * (2 * dist / vec_norm)).cast<coord_t>();
pt.rotate(angle, current_point);
pt = (current_pos + vec_dist * (2 * dist / vec_norm)).cast<coord_t>();
pt.rotate(angle, current_point);
// use extrude instead of travel_to_xy to trigger the unretract
ExtrusionPath fake_path_wipe(Polyline{pt, current_point}, paths.front());
fake_path_wipe.mm3_per_mm = 0;
gcode += extrude_path(fake_path_wipe, "move inwards before retraction/seam", speed);
}
bool is_small_peri = false;
for (ExtrusionPaths::iterator path = paths.begin(); path != paths.end(); ++path) {
// description += ExtrusionLoop::role_to_string(loop.loop_role());

View file

@ -123,6 +123,7 @@ static double calc_max_layer_height(const PrintConfig &config, double max_object
// (print->config().print_sequence == PrintSequence::ByObject is true).
ToolOrdering::ToolOrdering(const PrintObject &object, unsigned int first_extruder, bool prime_multi_material)
{
m_is_BBL_printer = object.print()->is_BBL_printer();
m_print_object_ptr = &object;
if (object.layers().empty())
return;
@ -162,6 +163,7 @@ ToolOrdering::ToolOrdering(const PrintObject &object, unsigned int first_extrude
// (print->config().print_sequence == PrintSequence::ByObject is false).
ToolOrdering::ToolOrdering(const Print &print, unsigned int first_extruder, bool prime_multi_material)
{
m_is_BBL_printer = print.is_BBL_printer();
m_print_config_ptr = &print.config();
// Initialize the print layers for all objects and all layers.
@ -757,24 +759,23 @@ void ToolOrdering::reorder_extruders_for_minimum_flush_volume()
const unsigned int number_of_extruders = (unsigned int) (sqrt(flush_matrix.size()) + EPSILON);
// Extract purging volumes for each extruder pair:
std::vector<std::vector<float>> wipe_volumes;
if (m_print_config_ptr->purge_in_prime_tower) {
if (print_config->purge_in_prime_tower || m_is_BBL_printer) {
for (unsigned int i = 0; i < number_of_extruders; ++i)
wipe_volumes.push_back(
std::vector<float>(flush_matrix.begin() + i * number_of_extruders, flush_matrix.begin() + (i + 1) * number_of_extruders));
wipe_volumes.push_back( std::vector<float>(flush_matrix.begin() + i * number_of_extruders,
flush_matrix.begin() + (i + 1) * number_of_extruders));
} else {
// populate wipe_volumes with prime_volume
for (unsigned int i = 0; i < number_of_extruders; ++i) {
wipe_volumes.push_back(std::vector<float>(number_of_extruders, m_print_config_ptr->prime_volume));
}
for (unsigned int i = 0; i < number_of_extruders; ++i)
wipe_volumes.push_back(std::vector<float>(number_of_extruders, print_config->prime_volume));
}
unsigned int current_extruder_id = -1;
for (int i = 0; i < m_layer_tools.size(); ++i) {
LayerTools& lt = m_layer_tools[i];
if (lt.extruders.empty())
continue;
// todo: The algorithm complexity is too high(o(n2)), currently only 8 colors are supported
if (i != 0 && lt.extruders.size() <= 8) {
// todo: The algorithm complexity is too high(o(n2)), currently only 12 colors are supported
if (i != 0 && lt.extruders.size() <= 12) {
lt.extruders = get_extruders_order(wipe_volumes, lt.extruders, current_extruder_id);
}
current_extruder_id = lt.extruders.back();

View file

@ -210,6 +210,7 @@ private:
const PrintConfig* m_print_config_ptr = nullptr;
const PrintObject* m_print_object_ptr = nullptr;
bool m_is_BBL_printer = false;
};
} // namespace SLic3r

View file

@ -1505,6 +1505,8 @@ void PerimeterGenerator::process_classic()
const Surface &surface = this->slices->surfaces[surface_order[order_idx]];
// detect how many perimeters must be generated for this island
int loop_number = this->config->wall_loops + surface.extra_perimeters - 1; // 0-indexed loops
if (this->config->alternate_extra_wall && this->layer_id % 2 == 1 && !m_spiral_vase) // add alternating extra wall
loop_number++;
if (this->layer_id == 0 && this->config->only_one_wall_first_layer)
loop_number = 0;
// Set the topmost layer to be one wall
@ -1937,6 +1939,8 @@ void PerimeterGenerator::process_arachne()
coord_t bead_width_0 = ext_perimeter_spacing;
// detect how many perimeters must be generated for this island
int loop_number = this->config->wall_loops + surface.extra_perimeters - 1; // 0-indexed loops
if (this->config->alternate_extra_wall && this->layer_id % 2 == 1 && !m_spiral_vase) // add alternating extra wall
loop_number++;
if (this->layer_id == 0 && this->config->only_one_wall_first_layer)
loop_number = 0;
// Orca: set the topmost layer to be one wall according to the config

View file

@ -766,7 +766,7 @@ bool Preset::has_cali_lines(PresetBundle* preset_bundle)
}
static std::vector<std::string> s_Preset_print_options {
"layer_height", "initial_layer_print_height", "wall_loops", "slice_closing_radius", "spiral_mode", "spiral_mode_smooth", "spiral_mode_max_xy_smoothing", "slicing_mode",
"layer_height", "initial_layer_print_height", "wall_loops", "alternate_extra_wall", "slice_closing_radius", "spiral_mode", "spiral_mode_smooth", "spiral_mode_max_xy_smoothing", "slicing_mode",
"top_shell_layers", "top_shell_thickness", "bottom_shell_layers", "bottom_shell_thickness",
"extra_perimeters_on_overhangs", "ensure_vertical_shell_thickness", "reduce_crossing_wall", "detect_thin_wall", "detect_overhang_wall", "overhang_reverse", "overhang_reverse_threshold","overhang_reverse_internal_only",
"seam_position", "staggered_inner_seams", "wall_sequence", "is_infill_first", "sparse_infill_density", "sparse_infill_pattern", "top_surface_pattern", "bottom_surface_pattern",
@ -808,7 +808,7 @@ static std::vector<std::string> s_Preset_print_options {
"small_perimeter_speed", "small_perimeter_threshold","bridge_angle", "filter_out_gap_fill", "travel_acceleration","inner_wall_acceleration", "min_width_top_surface",
"default_jerk", "outer_wall_jerk", "inner_wall_jerk", "infill_jerk", "top_surface_jerk", "initial_layer_jerk","travel_jerk",
"top_solid_infill_flow_ratio","bottom_solid_infill_flow_ratio","only_one_wall_first_layer", "print_flow_ratio", "seam_gap",
"role_based_wipe_speed", "wipe_speed", "accel_to_decel_enable", "accel_to_decel_factor", "wipe_on_loops",
"role_based_wipe_speed", "wipe_speed", "accel_to_decel_enable", "accel_to_decel_factor", "wipe_on_loops", "wipe_before_external_loop",
"bridge_density", "precise_outer_wall", "overhang_speed_classic", "bridge_acceleration",
"sparse_infill_acceleration", "internal_solid_infill_acceleration", "tree_support_adaptive_layer_height", "tree_support_auto_brim",
"tree_support_brim_width", "gcode_comments", "gcode_label_objects",
@ -878,7 +878,7 @@ static std::vector<std::string> s_Preset_printer_options {
"cooling_tube_retraction",
"cooling_tube_length", "high_current_on_filament_swap", "parking_pos_retraction", "extra_loading_move", "purge_in_prime_tower", "enable_filament_ramming",
"z_offset",
"disable_m73", "preferred_orientation"
"disable_m73", "preferred_orientation", "emit_machine_limits_to_gcode"
};
static std::vector<std::string> s_Preset_sla_print_options {

View file

@ -5,6 +5,7 @@
#include "Utils.hpp"
#include "Model.hpp"
#include "format.hpp"
#include "libslic3r_version.h"
#include <algorithm>
#include <set>
@ -462,7 +463,7 @@ std::string PresetBundle::get_texture_for_printer_model(std::string model_name)
{
for (auto vendor_model: vendor_profile.second.models)
{
if (vendor_model.name == model_name)
if (vendor_model.name == model_name || vendor_model.id == model_name)
{
texture_name = vendor_model.bed_texture;
vendor_name = vendor_profile.first;
@ -675,7 +676,7 @@ PresetsConfigSubstitutions PresetBundle::import_presets(std::vector<std::string>
import_json_presets(substitutions, file, override_confirm, rule, overwrite, result);
}
// Determine if it is a preset bundle
if (boost::iends_with(file, ".bbscfg") || boost::iends_with(file, ".bbsflmt") || boost::iends_with(file, ".zip")) {
if (boost::iends_with(file, ".orca_printer") || boost::iends_with(file, ".orca_filament") || boost::iends_with(file, ".zip")) {
boost::system::error_code ec;
// create user folder
fs::path user_folder(data_dir() + "/" + PRESET_USER_DIR);
@ -767,7 +768,7 @@ bool PresetBundle::import_json_presets(PresetsConfigSubstitutions & s
std::string version_str = key_values[BBL_JSON_KEY_VERSION];
boost::optional<Semver> version = Semver::parse(version_str);
if (!version) return false;
Semver app_version = *(Semver::parse(SLIC3R_VERSION));
Semver app_version = *(Semver::parse(SoftFever_VERSION));
if (version->maj() != app_version.maj()) {
BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << " Preset incompatibla, not loading: " << name;
return false;

View file

@ -487,7 +487,7 @@ void PrintConfigDef::init_common_params()
def = this->add("print_host", coString);
def->label = L("Hostname, IP or URL");
def->tooltip = L("Slic3r can upload G-code files to a printer host. This field should contain "
def->tooltip = L("Orca Slicer can upload G-code files to a printer host. This field should contain "
"the hostname, IP address or URL of the printer host instance. "
"Print host behind HAProxy with basic auth enabled can be accessed by putting the user name and password into the URL "
"in the following format: https://username:password@your-octopi-address/");
@ -505,7 +505,7 @@ void PrintConfigDef::init_common_params()
def = this->add("printhost_apikey", coString);
def->label = L("API Key / Password");
def->tooltip = L("Slic3r can upload G-code files to a printer host. This field should contain "
def->tooltip = L("Orca Slicer can upload G-code files to a printer host. This field should contain "
"the API Key or the password required for authentication.");
def->mode = comAdvanced;
def->cli = ConfigOptionDef::nocli;
@ -1633,7 +1633,7 @@ def = this->add("filament_loading_speed", coFloats);
def->label = L("Minimal purge on wipe tower");
def->tooltip = L("After a tool change, the exact position of the newly loaded filament inside "
"the nozzle may not be known, and the filament pressure is likely not yet stable. "
"Before purging the print head into an infill or a sacrificial object, Slic3r will always prime "
"Before purging the print head into an infill or a sacrificial object, Orca Slicer will always prime "
"this amount of material into the wipe tower to produce successive infill or sacrificial object extrusions reliably.");
def->sidetext = L("mm³");
def->min = 0;
@ -1837,7 +1837,7 @@ def = this->add("filament_loading_speed", coFloats);
def->label = L("Sparse infill anchor length");
def->category = L("Strength");
def->tooltip = L("Connect an infill line to an internal perimeter with a short segment of an additional perimeter. "
"If expressed as percentage (example: 15%) it is calculated over infill extrusion width. Slic3r tries to connect two close infill lines to a short perimeter segment. If no such perimeter segment "
"If expressed as percentage (example: 15%) it is calculated over infill extrusion width. Orca Slicer tries to connect two close infill lines to a short perimeter segment. If no such perimeter segment "
"shorter than infill_anchor_max is found, the infill line is connected to a perimeter segment at just one side "
"and the length of the perimeter segment taken is limited to this parameter, but no longer than anchor_length_max. "
"\nSet this parameter to zero to disable anchoring perimeters connected to a single infill line.");
@ -1864,7 +1864,7 @@ def = this->add("filament_loading_speed", coFloats);
def->label = L("Maximum length of the infill anchor");
def->category = L("Strength");
def->tooltip = L("Connect an infill line to an internal perimeter with a short segment of an additional perimeter. "
"If expressed as percentage (example: 15%) it is calculated over infill extrusion width. Slic3r tries to connect two close infill lines to a short perimeter segment. If no such perimeter segment "
"If expressed as percentage (example: 15%) it is calculated over infill extrusion width. Orca Slicer tries to connect two close infill lines to a short perimeter segment. If no such perimeter segment "
"shorter than this parameter is found, the infill line is connected to a perimeter segment at just one side "
"and the length of the perimeter segment taken is limited to infill_anchor, but no longer than this parameter. "
"\nIf set to 0, the old algorithm for infill connection will be used, it should create the same result as with 1000 & 0.");
@ -2367,7 +2367,7 @@ def = this->add("filament_loading_speed", coFloats);
def->label = L("Exclude objects");
def->tooltip = L("Enable this option to add EXCLUDE OBJECT command in g-code");
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionBool(1));
def->set_default_value(new ConfigOptionBool(false));
def = this->add("gcode_comments", coBool);
def->label = L("Verbose G-code");
@ -2564,6 +2564,14 @@ def = this->add("filament_loading_speed", coFloats);
def->mode = comDevelop;
def->set_default_value(new ConfigOptionBool(false));
def = this->add("emit_machine_limits_to_gcode", coBool);
def->label = L("Emit limits to G-code");
def->category = L("Machine limits");
def->tooltip = L("If enabled, the machine limits will be emitted to G-code file.\nThis option will be ignored if the g-code flavor is "
"set to Klipper.");
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionBool(true));
def = this->add("machine_pause_gcode", coString);
def->label = L("Pause G-code");
def->tooltip = L("This G-code will be used as a code for the pause print. User can insert pause G-code in gcode viewer");
@ -2818,7 +2826,7 @@ def = this->add("filament_loading_speed", coFloats);
def = this->add("host_type", coEnum);
def->label = L("Host Type");
def->tooltip = L("Slic3r can upload G-code files to a printer host. This field must contain "
def->tooltip = L("Orca Slicer can upload G-code files to a printer host. This field must contain "
"the kind of the host.");
def->enum_keys_map = &ConfigOptionEnum<PrintHostType>::get_enum_values();
def->enum_values.push_back("prusalink");
@ -3001,12 +3009,19 @@ def = this->add("filament_loading_speed", coFloats);
def->max = 1000;
def->set_default_value(new ConfigOptionInt(2));
def = this->add("alternate_extra_wall", coBool);
def->label = L("Alternate extra wall");
def->category = L("Strength");
def->tooltip = L("This setting adds an extra wall to every other layer. This way the infill gets wedged vertically between the walls, resulting in stronger prints. \n\nWhen this option is enabled, the ensure vertical shell thickness option needs to be disabled. \n\nUsing lightning infill together with this option is not recommended as there is limited infill to anchor the extra perimeters to.");
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionBool(false));
def = this->add("post_process", coStrings);
def->label = L("Post-processing Scripts");
def->tooltip = L("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.");
"and they can access the Orca Slicer config settings by reading environment variables.");
def->gui_flags = "serialized";
def->multiline = true;
def->full_width = true;
@ -3312,6 +3327,16 @@ def = this->add("filament_loading_speed", coFloats);
def->tooltip = L("To minimize the visibility of the seam in a closed loop extrusion, a small inward movement is executed before the extruder leaves the loop.");
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionBool(false));
def = this->add("wipe_before_external_loop", coBool);
def->label = L("Wipe before external loop");
def->tooltip = L("To minimise visibility of potential overextrusion at the start of an external perimeter when printing with "
"Outer/Inner or Inner/Outer/Inner wall print order, the deretraction is performed slightly on the inside from the "
"start of the external perimeter. That way any potential over extrusion is hidden from the outside surface. \n\nThis "
"is useful when printing with Outer/Inner or Inner/Outer/Inner wall print order as in these modes it is more likely "
"an external perimeter is printed immediately after a deretraction move.");
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionBool(false));
def = this->add("wipe_speed", coFloatOrPercent);
def->label = L("Wipe speed");
@ -4436,8 +4461,8 @@ def = this->add("filament_loading_speed", coFloats);
def->label = L("Use relative E distances");
def->tooltip = L("Relative extrusion is recommended when using \"label_objects\" option."
"Some extruders work better with this option unckecked (absolute extrusion mode). "
"Wipe tower is only compatible with relative mode. It is always enabled on "
"BambuLab printers. Default is checked");
"Wipe tower is only compatible with relative mode. It is recommended on "
"most printers. Default is checked");
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionBool(true));
@ -5494,6 +5519,7 @@ void DynamicPrintConfig::normalize_fdm(int used_filaments)
}
{
this->opt<ConfigOptionInt>("wall_loops", true)->value = 1;
this->opt<ConfigOptionBool>("alternate_extra_wall", true)->value = false;
this->opt<ConfigOptionInt>("top_shell_layers", true)->value = 0;
this->opt<ConfigOptionPercent>("sparse_infill_density", true)->value = 0;
}
@ -5566,6 +5592,7 @@ void DynamicPrintConfig::normalize_fdm_1()
}
{
this->opt<ConfigOptionInt>("wall_loops", true)->value = 1;
this->opt<ConfigOptionBool>("alternate_extra_wall", true)->value = false;
this->opt<ConfigOptionInt>("top_shell_layers", true)->value = 0;
this->opt<ConfigOptionPercent>("sparse_infill_density", true)->value = 0;
}

View file

@ -853,6 +853,7 @@ PRINT_CONFIG_CLASS_DEFINE(
((ConfigOptionFloat, inner_wall_speed))
// Total number of perimeters.
((ConfigOptionInt, wall_loops))
((ConfigOptionBool, alternate_extra_wall))
((ConfigOptionFloat, minimum_sparse_infill_area))
((ConfigOptionInt, solid_infill_filament))
((ConfigOptionFloatOrPercent, internal_solid_infill_line_width))
@ -879,6 +880,7 @@ PRINT_CONFIG_CLASS_DEFINE(
((ConfigOptionBool, role_based_wipe_speed))
((ConfigOptionFloatOrPercent, wipe_speed))
((ConfigOptionBool, wipe_on_loops))
((ConfigOptionBool, wipe_before_external_loop))
((ConfigOptionEnum<WallInfillOrder>, wall_infill_order))
((ConfigOptionBool, precise_outer_wall))
((ConfigOptionBool, overhang_speed_classic))
@ -906,6 +908,8 @@ PRINT_CONFIG_CLASS_DEFINE(
PRINT_CONFIG_CLASS_DEFINE(
MachineEnvelopeConfig,
// Orca: whether emit machine limits into the beginning of the G-code.
((ConfigOptionBool, emit_machine_limits_to_gcode))
// M201 X... Y... Z... E... [mm/sec^2]
((ConfigOptionFloats, machine_max_acceleration_x))
((ConfigOptionFloats, machine_max_acceleration_y))

View file

@ -911,6 +911,7 @@ bool PrintObject::invalidate_state_by_config_options(
}
} else if (
opt_key == "wall_loops"
|| opt_key == "alternate_extra_wall"
|| opt_key == "top_one_wall_type"
|| opt_key == "min_width_top_surface"
|| opt_key == "only_one_wall_first_layer"

View file

@ -284,6 +284,9 @@ static std::string g_data_dir;
void set_data_dir(const std::string &dir)
{
g_data_dir = dir;
if (!g_data_dir.empty() && !boost::filesystem::exists(g_data_dir)) {
boost::filesystem::create_directory(g_data_dir);
}
}
const std::string& data_dir()

1
src/nanosvg/README.txt Normal file
View file

@ -0,0 +1 @@
Upstream source: https://github.com/SoftFever/nanosvg

3120
src/nanosvg/nanosvg.h Normal file

File diff suppressed because it is too large Load diff

1483
src/nanosvg/nanosvgrast.h Normal file

File diff suppressed because it is too large Load diff

View file

@ -526,8 +526,6 @@ set(SLIC3R_GUI_SOURCES
Utils/CalibUtils.hpp
)
find_package(NanoSVG REQUIRED)
if (WIN32)
list(APPEND SLIC3R_GUI_SOURCES
GUI/dark_mode/dark_mode.hpp
@ -575,7 +573,7 @@ source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${SLIC3R_GUI_SOURCES})
encoding_check(libslic3r_gui)
target_link_libraries(libslic3r_gui libslic3r cereal::cereal imgui minilzo GLEW::GLEW OpenGL::GL hidapi ${wxWidgets_LIBRARIES} glfw libcurl OpenSSL::SSL OpenSSL::Crypto NanoSVG::nanosvg NanoSVG::nanosvgrast)
target_link_libraries(libslic3r_gui libslic3r cereal::cereal imgui minilzo GLEW::GLEW OpenGL::GL hidapi ${wxWidgets_LIBRARIES} glfw libcurl OpenSSL::SSL OpenSSL::Crypto)
#target_link_libraries(libslic3r_gui libslic3r cereal imgui minilzo GLEW::GLEW OpenGL::GL hidapi libcurl OpenSSL::SSL OpenSSL::Crypto ${wxWidgets_LIBRARIES} glfw)
if (MSVC)

View file

@ -1084,7 +1084,7 @@ void AMSMaterialsSetting::on_dpi_changed(const wxRect &suggested_rect)
m_input_nozzle_max->GetTextCtrl()->SetSize(wxSize(-1, FromDIP(20)));
m_input_nozzle_min->GetTextCtrl()->SetSize(wxSize(-1, FromDIP(20)));
//m_clr_picker->msw_rescale();
degree->sys_color_changed();
degree->msw_rescale();
bitmap_max_degree->SetBitmap(degree->bmp());
bitmap_min_degree->SetBitmap(degree->bmp());
m_button_reset->SetMinSize(AMS_MATERIALS_SETTING_BUTTON_SIZE);

View file

@ -19,7 +19,7 @@ AboutDialogLogo::AboutDialogLogo(wxWindow* parent)
{
this->SetBackgroundColour(*wxWHITE);
this->logo = ScalableBitmap(this, Slic3r::var("OrcaSlicer_192px.png"), wxBITMAP_TYPE_PNG);
this->SetMinSize(this->logo.GetSize());
this->SetMinSize(this->logo.GetBmpSize());
this->Bind(wxEVT_PAINT, &AboutDialogLogo::onRepaint, this);
}
@ -30,9 +30,9 @@ void AboutDialogLogo::onRepaint(wxEvent &event)
dc.SetBackgroundMode(wxTRANSPARENT);
wxSize size = this->GetSize();
int logo_w = this->logo.GetWidth();
int logo_h = this->logo.GetHeight();
dc.DrawBitmap(this->logo.get_bitmap(), (size.GetWidth() - logo_w)/2, (size.GetHeight() - logo_h)/2, true);
int logo_w = this->logo.GetBmpWidth();
int logo_h = this->logo.GetBmpHeight();
dc.DrawBitmap(this->logo.bmp(), (size.GetWidth() - logo_w)/2, (size.GetHeight() - logo_h)/2, true);
event.Skip();
}
@ -380,7 +380,7 @@ AboutDialog::AboutDialog()
void AboutDialog::on_dpi_changed(const wxRect &suggested_rect)
{
m_logo_bitmap.sys_color_changed();
m_logo_bitmap.msw_rescale();
m_logo->SetBitmap(m_logo_bitmap.bmp());
const wxFont& font = GetFont();

View file

@ -187,7 +187,7 @@ void MaterialItem::doRender(wxDC &dc)
auto acolor = m_ams_coloul;
if (mcolor.Alpha() == 0 || acolor.Alpha() == 0) {
dc.DrawBitmap(m_transparent_mitem.get_bitmap(), FromDIP(1), FromDIP(1));
dc.DrawBitmap(m_transparent_mitem.bmp(), FromDIP(1), FromDIP(1));
}
if (!IsEnabled()) {
@ -247,10 +247,10 @@ void MaterialItem::doRender(wxDC &dc)
//arrow
if ( (acolor.Red() > 160 && acolor.Green() > 160 && acolor.Blue() > 160) &&
(acolor.Red() < 180 && acolor.Green() < 180 && acolor.Blue() < 180)) {
dc.DrawBitmap(m_arraw_bitmap_white.get_bitmap(), GetSize().x - m_arraw_bitmap_white.GetSize().x - FromDIP(7), GetSize().y - m_arraw_bitmap_white.GetSize().y);
dc.DrawBitmap(m_arraw_bitmap_white.bmp(), GetSize().x - m_arraw_bitmap_white.GetBmpSize().x - FromDIP(7), GetSize().y - m_arraw_bitmap_white.GetBmpSize().y);
}
else {
dc.DrawBitmap(m_arraw_bitmap_gray.get_bitmap(), GetSize().x - m_arraw_bitmap_gray.GetSize().x - FromDIP(7), GetSize().y - m_arraw_bitmap_gray.GetSize().y);
dc.DrawBitmap(m_arraw_bitmap_gray.bmp(), GetSize().x - m_arraw_bitmap_gray.GetBmpSize().x - FromDIP(7), GetSize().y - m_arraw_bitmap_gray.GetBmpSize().y);
}
@ -677,7 +677,7 @@ void MappingItem::doRender(wxDC &dc)
dc.SetBrush(wxBrush(m_coloul));
if (m_coloul.Alpha() == 0) {
dc.DrawBitmap( m_transparent_mapping_item.get_bitmap(), 0, (GetSize().y - MAPPING_ITEM_REAL_SIZE.y) / 2);
dc.DrawBitmap( m_transparent_mapping_item.bmp(), 0, (GetSize().y - MAPPING_ITEM_REAL_SIZE.y) / 2);
}
else {
dc.DrawRectangle(0, (GetSize().y - MAPPING_ITEM_REAL_SIZE.y) / 2, MAPPING_ITEM_REAL_SIZE.x, MAPPING_ITEM_REAL_SIZE.y);
@ -1340,7 +1340,7 @@ void AmsReplaceMaterialDialog::update_machine_obj(MachineObject* obj)
}
else {
label_txt->SetLabelText(_L("If there are two identical filaments in AMS, AMS filament backup will be enabled. \n(Currently supporting automatic supply of consumables with the same brand, material type, and color)"));
}
}
label_txt->SetMinSize(wxSize(FromDIP(380), -1));
label_txt->SetMaxSize(wxSize(FromDIP(380), -1));
@ -1494,7 +1494,7 @@ void AmsRMGroup::doRender(wxDC& dc)
float startAngle = 0.0;
float endAngle = 0.0;
dc.DrawBitmap(bitmap_bg.get_bitmap(), wxPoint((size.x - bitmap_bg.GetSize().x) / 2, (size.y - bitmap_bg.GetSize().y) / 2));
dc.DrawBitmap(bitmap_bg.bmp(), wxPoint((size.x - bitmap_bg.GetBmpSize().x) / 2, (size.y - bitmap_bg.GetBmpSize().y) / 2));
for (auto iter = m_group_info.rbegin(); iter != m_group_info.rend(); ++iter) {
std::string tray_name = iter->first;
@ -1575,7 +1575,7 @@ void AmsRMGroup::doRender(wxDC& dc)
dc.DrawEllipticArc(x - center_mask_radius, y - center_mask_radius, center_mask_radius * 2, center_mask_radius * 2, 0, 360);
//draw center icon
dc.DrawBitmap(bitmap_backup_tips_0.get_bitmap(), wxPoint((size.x - bitmap_backup_tips_0.GetSize().x) / 2, (size.y - bitmap_backup_tips_0.GetSize().y) / 2));
dc.DrawBitmap(bitmap_backup_tips_0.bmp(), wxPoint((size.x - bitmap_backup_tips_0.GetBmpSize().x) / 2, (size.y - bitmap_backup_tips_0.GetBmpSize().y) / 2));
//dc.DrawBitmap(bitmap_backup_tips_1.bmp(), wxPoint((size.x - bitmap_backup_tips_1.GetBmpSize().x) / 2, (size.y - bitmap_backup_tips_1.GetBmpSize().y) / 2));
//draw material

View file

@ -226,7 +226,7 @@ void AuFile::PaintBackground(wxDC &dc)
dc.SetPen(AUFILE_GREY200);
dc.SetBrush(AUFILE_GREY200);
dc.DrawRoundedRectangle(0, 0, size.x, size.y, AUFILE_ROUNDING);
dc.DrawBitmap(m_file_bitmap.get_bitmap(), (size.x - m_file_bitmap.GetWidth()) / 2, (size.y - m_file_bitmap.GetHeight()) / 2);
dc.DrawBitmap(m_file_bitmap.bmp(), (size.x - m_file_bitmap.GetBmpWidth()) / 2, (size.y - m_file_bitmap.GetBmpHeight()) / 2);
}
}
@ -257,7 +257,7 @@ void AuFile::PaintForeground(wxDC &dc)
}
if (m_type == MODEL_PICTURE) {
dc.DrawBitmap(m_file_edit_mask.get_bitmap(), 0, size.y - m_file_edit_mask.GetSize().y);
dc.DrawBitmap(m_file_edit_mask.bmp(), 0, size.y - m_file_edit_mask.GetBmpSize().y);
}
@ -268,14 +268,14 @@ void AuFile::PaintForeground(wxDC &dc)
auto sizet = dc.GetTextExtent(cover_text_left);
auto pos = wxPoint(0, 0);
pos.x = (size.x / 2 - sizet.x) / 2;
pos.y = (size.y - (m_file_edit_mask.GetSize().y + sizet.y) / 2);
pos.y = (size.y - (m_file_edit_mask.GetBmpSize().y + sizet.y) / 2);
dc.DrawText(cover_text_left, pos);
// right text
sizet = dc.GetTextExtent(cover_text_right);
pos = wxPoint(0, 0);
pos.x = size.x / 2 + (size.x / 2 - sizet.x) / 2;
pos.y = (size.y - (m_file_edit_mask.GetSize().y + sizet.y) / 2);
pos.y = (size.y - (m_file_edit_mask.GetBmpSize().y + sizet.y) / 2);
dc.DrawText(cover_text_right, pos);
// Split
@ -283,7 +283,7 @@ void AuFile::PaintForeground(wxDC &dc)
dc.SetBrush(*wxWHITE);
pos = wxPoint(0, 0);
pos.x = size.x / 2 - 1;
pos.y = size.y - FromDIP(24) - (m_file_edit_mask.GetSize().y - FromDIP(24)) / 2;
pos.y = size.y - FromDIP(24) - (m_file_edit_mask.GetBmpSize().y - FromDIP(24)) / 2;
dc.DrawRectangle(pos.x, pos.y, 2, FromDIP(24));
} else {
// right text
@ -297,7 +297,7 @@ void AuFile::PaintForeground(wxDC &dc)
if (m_cover) {
dc.SetTextForeground(*wxWHITE);
dc.DrawBitmap(m_file_cover.get_bitmap(), size.x - m_file_cover.GetSize().x, 0);
dc.DrawBitmap(m_file_cover.bmp(), size.x - m_file_cover.GetBmpSize().x, 0);
dc.SetFont(Label::Body_12);
auto sizet = dc.GetTextExtent(cover_text_cover);
auto pos = wxPoint(0, 0);
@ -306,7 +306,7 @@ void AuFile::PaintForeground(wxDC &dc)
dc.DrawText(cover_text_cover, pos);
}
if (m_hover) { dc.DrawBitmap(m_file_delete.get_bitmap(), size.x - m_file_delete.GetSize().x - FromDIP(10), FromDIP(10)); }
if (m_hover) { dc.DrawBitmap(m_file_delete.bmp(), size.x - m_file_delete.GetBmpSize().x - FromDIP(10), FromDIP(10)); }
}
void AuFile::on_mouse_enter(wxMouseEvent &evt)
@ -421,7 +421,7 @@ void AuFile::on_mouse_left_up(wxMouseEvent &evt)
auto pos = evt.GetPosition();
// set cover
auto mask_size = wxSize(GetSize().x, m_file_edit_mask.GetSize().y);
auto mask_size = wxSize(GetSize().x, m_file_edit_mask.GetBmpSize().y);
auto cover_left = 0;
auto cover_top = size.y - mask_size.y;
auto cover_right = mask_size.x / 2;
@ -443,10 +443,10 @@ void AuFile::on_mouse_left_up(wxMouseEvent &evt)
if (pos.x > rename_left && pos.x < rename_right && pos.y > rename_top && pos.y < rename_bottom) { on_set_rename(); return; }
// close
auto close_left = size.x - m_file_delete.GetSize().x - FromDIP(10);
auto close_left = size.x - m_file_delete.GetBmpSize().x - FromDIP(10);
auto close_top = FromDIP(10);
auto close_right = size.x - FromDIP(10);
auto close_bottom = m_file_delete.GetSize().y + FromDIP(10);
auto close_bottom = m_file_delete.GetBmpSize().y + FromDIP(10);
if (pos.x > close_left && pos.x < close_right && pos.y > close_top && pos.y < close_bottom) { on_set_delete(); return; }
exit_rename_mode();

View file

@ -93,7 +93,9 @@ void BBLTopbarArt::DrawButton(wxDC& dc, wxWindow* wnd, const wxAuiToolBarItem& i
int bmpX = 0, bmpY = 0;
int textX = 0, textY = 0;
const wxBitmap &bmp = item.GetCurrentBitmapFor(wnd);
const wxBitmap& bmp = item.GetState() & wxAUI_BUTTON_STATE_DISABLED
? item.GetDisabledBitmap()
: item.GetBitmap();
const wxSize bmpSize = bmp.IsOk() ? bmp.GetScaledSize() : wxSize(0, 0);
@ -531,15 +533,6 @@ void BBLTopbar::OnFullScreen(wxAuiToolBarEvent& event)
m_frame->Restore();
}
else {
wxDisplay display(this);
auto size = display.GetClientArea().GetSize();
#ifdef __WXMSW__
HWND hWnd = m_frame->GetHandle();
RECT borderThickness;
SetRectEmpty(&borderThickness);
AdjustWindowRectEx(&borderThickness, GetWindowLongPtr(hWnd, GWL_STYLE), FALSE, 0);
m_frame->SetMaxSize(size + wxSize{-borderThickness.left + borderThickness.right, -borderThickness.top + borderThickness.bottom});
#endif // __WXMSW__
m_normalRect = m_frame->GetRect();
m_frame->Maximize();
}

View file

@ -13,8 +13,10 @@
#include <wx/rawbmp.h>
#endif /* __WXGTK2__ */
#include <nanosvg/nanosvg.h>
#include <nanosvg/nanosvgrast.h>
#define NANOSVG_IMPLEMENTATION
#include "nanosvg/nanosvg.h"
#define NANOSVGRAST_IMPLEMENTATION
#include "nanosvg/nanosvgrast.h"
namespace Slic3r { namespace GUI {
@ -58,168 +60,7 @@ static wxBitmap wxImage_to_wxBitmap_with_alpha(wxImage &&image, float scale = 1.
#endif
}
wxBitmapBundle* BitmapCache::insert_bndl(const std::string& name, const std::vector<wxBitmapBundle*>& bmps)
{
wxVector<wxBitmap> bitmaps;
std::set<double> scales = {1.0};
#ifndef __linux__
#ifdef __APPLE__
scales.emplace(m_scale);
#else
size_t disp_cnt = wxDisplay::GetCount();
for (size_t disp = 0; disp < disp_cnt; ++disp)
scales.emplace(wxDisplay(disp).GetScaleFactor());
#endif
#endif // !__linux__
for (double scale : scales) {
size_t width = 0;
size_t height = 0;
for (const wxBitmapBundle* bmp_bndl : bmps) {
#ifdef __APPLE__
wxSize size = bmp_bndl->GetDefaultSize();
#else
wxSize size = bmp_bndl->GetPreferredBitmapSizeAtScale(scale);
#endif
width += size.GetWidth();
height = std::max<size_t>(height, size.GetHeight());
}
std::string bitmap_key = name + "," +float_to_string_decimal_point(scale);
#ifdef __WXGTK2__
// Broken alpha workaround
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 wxBitmapBundle* bmp_bndl : bmps) {
wxBitmap bmp = bmp_bndl->GetBitmap(bmp_bndl->GetDefaultSize());
if (bmp.GetWidth() > 0) {
if (bmp.GetDepth() == 32) {
wxAlphaPixelData data(bmp);
//FIXME The following method is missing from wxWidgets 3.1.1.
// It looks like the wxWidgets 3.0.3 called the wrapped bitmap's UseAlpha().
//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(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.GetScaledWidth();
}
bitmaps.push_back(* this->insert(bitmap_key, wxImage_to_wxBitmap_with_alpha(std::move(image))));
#else
wxBitmap* bitmap = this->insert(bitmap_key, width, height, scale);
wxMemoryDC memDC;
memDC.SelectObject(*bitmap);
memDC.SetBackground(*wxTRANSPARENT_BRUSH);
memDC.Clear();
size_t x = 0;
for (const wxBitmapBundle* bmp_bndl : bmps) {
wxBitmap bmp = bmp_bndl->GetBitmap(bmp_bndl->GetPreferredBitmapSizeAtScale(scale));
if (bmp.GetWidth() > 0)
memDC.DrawBitmap(bmp, x, 0, true);
// we should "move" with step equal to non-scaled width
#ifdef __APPLE__
x += bmp.GetScaledWidth();
#else
x += bmp.GetWidth();
#endif
}
memDC.SelectObject(wxNullBitmap);
bitmaps.push_back(*bitmap);
#endif
}
return insert_bndl(name, bitmaps);
}
wxBitmapBundle* BitmapCache::insert_bndl(const std::string &bitmap_key, const char* data, size_t width, size_t height)
{
wxBitmapBundle* bndl = nullptr;
auto it = m_bndl_map.find(bitmap_key);
if (it == m_bndl_map.end()) {
bndl = new wxBitmapBundle(wxBitmapBundle::FromSVG(data, wxSize(width, height)));
m_bndl_map[bitmap_key] = bndl;
}
else {
bndl = it->second;
*bndl = wxBitmapBundle::FromSVG(data, wxSize(width, height));
}
return bndl;
}
wxBitmapBundle* BitmapCache::insert_bndl(const std::string& bitmap_key, const wxBitmapBundle& bmp)
{
wxBitmapBundle* bndl = nullptr;
auto it = m_bndl_map.find(bitmap_key);
if (it == m_bndl_map.end()) {
bndl = new wxBitmapBundle(bmp);
m_bndl_map[bitmap_key] = bndl;
}
else {
bndl = it->second;
*bndl = wxBitmapBundle(bmp);
}
return bndl;
}
wxBitmapBundle* BitmapCache::insert_bndl(const std::string& bitmap_key, const wxVector<wxBitmap>& bmps)
{
wxBitmapBundle* bndl = nullptr;
auto it = m_bndl_map.find(bitmap_key);
if (it == m_bndl_map.end()) {
bndl = new wxBitmapBundle(wxBitmapBundle::FromBitmaps(bmps));
m_bndl_map[bitmap_key] = bndl;
}
else {
bndl = it->second;
*bndl = wxBitmapBundle::FromBitmaps(bmps);
}
return bndl;
}
wxBitmap* BitmapCache::insert(const std::string &bitmap_key, size_t width, size_t height, double scale/* = -1.0*/)
wxBitmap* BitmapCache::insert(const std::string &bitmap_key, size_t width, size_t height)
{
wxBitmap *bitmap = nullptr;
auto it = m_map.find(bitmap_key);
@ -235,7 +76,7 @@ wxBitmap* BitmapCache::insert(const std::string &bitmap_key, size_t width, size_
// So, We need to let the Mac OS wxBitmap implementation
// know that the image may already be scaled appropriately for Retina,
// and thereby that it's not supposed to upscale it.
bitmap->CreateScaled(width, height, -1, scale < 0.0 ? m_scale : scale);
bitmap->CreateScaled(width, height, -1, m_scale);
#endif
m_map[bitmap_key] = bitmap;
} else {
@ -264,6 +105,110 @@ wxBitmap* BitmapCache::insert(const std::string &bitmap_key, const wxBitmap &bmp
return bitmap;
}
wxBitmap* BitmapCache::insert(const std::string &bitmap_key, const wxBitmap &bmp, const wxBitmap &bmp2)
{
// 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)
{
// 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) {
#ifdef __APPLE__
width += bmp->GetScaledWidth();
height = std::max<size_t>(height, bmp->GetScaledHeight());
#else
width += bmp->GetWidth();
height = std::max<size_t>(height, bmp->GetHeight());
#endif
}
#ifdef __WXGTK2__
// Broken alpha workaround
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<wxBitmap*>(bmp));
//FIXME The following method is missing from wxWidgets 3.1.1.
// It looks like the wxWidgets 3.0.3 called the wrapped bitmap's UseAlpha().
//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<wxBitmap*>(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();
size_t x = 0;
for (const wxBitmap *bmp = begin; bmp != end; ++ bmp) {
if (bmp->GetWidth() > 0)
memDC.DrawBitmap(*bmp, x, 0, true);
#ifdef __APPLE__
// we should "move" with step equal to non-scaled width
x += bmp->GetScaledWidth();
#else
x += bmp->GetWidth();
#endif
}
memDC.SelectObject(wxNullBitmap);
return bitmap;
#endif
}
wxBitmap* BitmapCache::insert_raw_rgba(const std::string &bitmap_key, unsigned width, unsigned height, const unsigned char *raw_data, const bool grayscale/* = false*/)
{
wxImage image(width, height);
@ -360,102 +305,7 @@ error:
return NULL;
}
void BitmapCache::nsvgGetDataFromFileWithReplace(const char* filename, std::string& data_str, const std::map<std::string, std::string>& replaces)
{
FILE* fp = NULL;
size_t size;
char* data = NULL;
fp = boost::nowide::fopen(filename, "rb");
if (!fp) goto error;
fseek(fp, 0, SEEK_END);
size = ftell(fp);
fseek(fp, 0, SEEK_SET);
data = (char*)malloc(size + 1);
if (data == NULL) goto error;
if (fread(data, 1, size, fp) != size) goto error;
data[size] = '\0'; // Must be null terminated.
fclose(fp);
data_str.assign(data);
for (auto val : replaces)
boost::replace_all(data_str, val.first, val.second);
free(data);
return;
error:
if (fp) fclose(fp);
if (data) free(data);
return;
}
wxBitmapBundle* BitmapCache::from_svg(const std::string& bitmap_name, unsigned target_width, unsigned target_height,
const bool dark_mode, const std::string& new_color /*= ""*/)
{
if (target_width == 0)
target_width = target_height;
std::string bitmap_key = bitmap_name + (target_height != 0 ?
"-h" + std::to_string(target_height) :
"-w" + std::to_string(target_width))
+ (dark_mode ? "-dm" : "")
+ new_color;
auto it = m_bndl_map.find(bitmap_key);
if (it != m_bndl_map.end())
return it->second;
// map of color replaces
//Orca: use replaces from load_svg function
std::map<std::string, std::string> replaces;
replaces["\"#0x00AE42\""] = "\"#009688\"";
replaces["\"#00FF00\""] = "\"#52c7b8\"";
if (dark_mode) {
replaces["\"#262E30\""] = "\"#EFEFF0\"";
replaces["\"#323A3D\""] = "\"#B3B3B5\"";
replaces["\"#808080\""] = "\"#818183\"";
replaces["\"#CECECE\""] = "\"#54545B\"";
replaces["\"#6B6B6B\""] = "\"#818182\"";
replaces["\"#909090\""] = "\"#FFFFFF\"";
replaces["\"#00FF00\""] = "\"#FF0000\"";
replaces["\"#009688\""] = "\"#00675b\"";
}
std::string str;
nsvgGetDataFromFileWithReplace(Slic3r::var(bitmap_name + ".svg").c_str(), str, replaces);
if (str.empty())
return nullptr;
return insert_bndl(bitmap_key, str.data(), target_width, target_height);
}
wxBitmapBundle* BitmapCache::from_png(const std::string& bitmap_name, unsigned width, unsigned height)
{
std::string bitmap_key = bitmap_name + (height != 0 ?
"-h" + std::to_string(height) :
"-w" + std::to_string(width));
auto it = m_bndl_map.find(bitmap_key);
if (it != m_bndl_map.end())
return it->second;
wxImage image;
if (!image.LoadFile(Slic3r::GUI::from_u8(Slic3r::var(bitmap_name + ".png")), wxBITMAP_TYPE_PNG) ||
image.GetWidth() == 0 || image.GetHeight() == 0)
return nullptr;
if (height != 0 && unsigned(image.GetHeight()) != height)
width = unsigned(0.5f + float(image.GetWidth()) * height / image.GetHeight());
else if (width != 0 && unsigned(image.GetWidth()) != width)
height = unsigned(0.5f + float(image.GetHeight()) * width / image.GetWidth());
if (height != 0 && width != 0)
image.Rescale(width, height, wxIMAGE_QUALITY_BILINEAR);
return this->insert_bndl(bitmap_key, wxImage_to_wxBitmap_with_alpha(std::move(image)));
}
wxBitmap* BitmapCache::load_svg(const std::string &bitmap_name, unsigned target_width, unsigned target_height,
wxBitmap* BitmapCache::load_svg(const std::string &bitmap_name, unsigned target_width, unsigned target_height,
const bool grayscale/* = false*/, const bool dark_mode/* = false*/, const std::string& new_color /*= ""*/, const float scale_in_center/* = 0*/)
{
std::string bitmap_key = bitmap_name + ( target_height !=0 ?
@ -472,7 +322,7 @@ wxBitmap* BitmapCache::load_svg(const std::string &bitmap_name, unsigned target_
// map of color replaces
std::map<std::string, std::string> replaces;
replaces["\"#0x00AE42\""] = "\"#009688\"";
replaces["\"#0x00AE42\""] = "\"#009688\"";
replaces["\"#00FF00\""] = "\"#52c7b8\"";
if (dark_mode) {
replaces["\"#262E30\""] = "\"#EFEFF0\"";
@ -483,7 +333,7 @@ wxBitmap* BitmapCache::load_svg(const std::string &bitmap_name, unsigned target_
replaces["\"#6B6B6B\""] = "\"#818182\"";
replaces["\"#909090\""] = "\"#FFFFFF\"";
replaces["\"#00FF00\""] = "\"#FF0000\"";
replaces["\"#009688\""] = "\"#00675b\"";
replaces["\"#009688\""] = "\"#00675b\"";
}
//if (!new_color.empty())
// replaces["\"#ED6B21\""] = "\"" + new_color + "\"";
@ -536,9 +386,9 @@ wxBitmap* BitmapCache::load_svg(const std::string &bitmap_name, unsigned target_
return this->insert_raw_rgba(bitmap_key, width, height, data.data(), grayscale);
}
/*
//we make scaled solid bitmaps only for the cases, when its will be used with scaled SVG icon in one output bitmap
wxBitmap BitmapCache::mksolid(size_t width, size_t height, unsigned char r, unsigned char g, unsigned char b, unsigned char transparency, bool suppress_scaling/* = false* /, size_t border_width /*= 0* /, bool dark_mode/* = false* /)
wxBitmap BitmapCache::mksolid(size_t width, size_t height, unsigned char r, unsigned char g, unsigned char b, unsigned char transparency, bool suppress_scaling/* = false*/, size_t border_width /*= 0*/, bool dark_mode/* = false*/)
{
double scale = suppress_scaling ? 1.0f : m_scale;
width *= scale;
@ -580,89 +430,6 @@ wxBitmap BitmapCache::mksolid(size_t width, size_t height, unsigned char r, unsi
return wxImage_to_wxBitmap_with_alpha(std::move(image), scale);
}
*/
//we make scaled solid bitmaps only for the cases, when its will be used with scaled SVG icon in one output bitmap
wxBitmapBundle BitmapCache::mksolid(size_t width_in, size_t height_in, unsigned char r, unsigned char g, unsigned char b, unsigned char transparency, size_t border_width /*= 0*/, bool dark_mode/* = false*/)
{
wxVector<wxBitmap> bitmaps;
std::set<double> scales = { 1.0 };
#ifndef __linux__
#ifdef __APPLE__
scales.emplace(m_scale);
#else
size_t disp_cnt = wxDisplay::GetCount();
for (size_t disp = 0; disp < disp_cnt; ++disp)
scales.emplace(wxDisplay(disp).GetScaleFactor());
#endif
#endif // !__linux__
for (double scale : scales) {
size_t width = width_in * scale;
size_t height = height_in * scale;
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;
}
// Add border, make white/light spools easier to see
if (border_width > 0) {
// Restrict to width of image
if (border_width > height) border_width = height - 1;
if (border_width > width) border_width = width - 1;
auto px_data = (uint8_t*)image.GetData();
auto a_data = (uint8_t*)image.GetAlpha();
for (size_t x = 0; x < width; ++x) {
for (size_t y = 0; y < height; ++y) {
if (x < border_width || y < border_width ||
x >= (width - border_width) || y >= (height - border_width)) {
const size_t idx = (x + y * width);
const size_t idx_rgb = (x + y * width) * 3;
px_data[idx_rgb] = px_data[idx_rgb + 1] = px_data[idx_rgb + 2] = dark_mode ? 245u : 110u;
a_data[idx] = 255u;
}
}
}
}
bitmaps.push_back(wxImage_to_wxBitmap_with_alpha(std::move(image), scale));
}
return wxBitmapBundle::FromBitmaps(bitmaps);
}
wxBitmapBundle* BitmapCache::mksolid_bndl(size_t width, size_t height, const std::string& color, size_t border_width, bool dark_mode)
{
std::string bitmap_key = (color.empty() ? "empty" : color) + "-h" + std::to_string(height) + "-w" + std::to_string(width) + (dark_mode ? "-dm" : "");
wxBitmapBundle* bndl = nullptr;
auto it = m_bndl_map.find(bitmap_key);
if (it == m_bndl_map.end()) {
if (color.empty())
bndl = new wxBitmapBundle(mksolid(width, height, 0, 0, 0, wxALPHA_TRANSPARENT, size_t(0)));
else {
ColorRGB rgb;// [3]
decode_color(color, rgb);
bndl = new wxBitmapBundle(mksolid(width, height, rgb.r_uchar(), rgb.g_uchar(), rgb.b_uchar(), wxALPHA_OPAQUE, border_width, dark_mode));
}
m_bndl_map[bitmap_key] = bndl;
}
else
return it->second;
return bndl;
}
bool BitmapCache::parse_color(const std::string& scolor, unsigned char* rgb_out)
{

View file

@ -12,8 +12,7 @@
#include "libslic3r/Color.hpp"
struct NSVGimage;
namespace Slic3r {
namespace GUI {
namespace Slic3r { namespace GUI {
class BitmapCache
{
@ -23,23 +22,15 @@ public:
void clear();
double scale() { return m_scale; }
wxBitmapBundle* find_bndl(const std::string &name) { auto it = m_bndl_map.find(name); return (it == m_bndl_map.end()) ? nullptr : it->second; }
const wxBitmapBundle* find_bndl(const std::string &name) const { return const_cast<BitmapCache*>(this)->find_bndl(name); }
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<BitmapCache*>(this)->find(name); }
wxBitmapBundle* insert_bndl(const std::string& bitmap_key, const char* data, size_t width, size_t height);
wxBitmapBundle* insert_bndl(const std::string& bitmap_key, const wxBitmapBundle &bmp);
wxBitmapBundle* insert_bndl(const std::string& bitmap_key, const wxVector<wxBitmap>& bmps);
wxBitmapBundle* insert_bndl(const std::string& name, const std::vector<wxBitmapBundle*>& bmps);
wxBitmapBundle* insert_raw_rgba_bndl(const std::string &bitmap_key, unsigned width, unsigned height, const unsigned char *raw_data, const bool grayscale = false);
wxBitmap* insert(const std::string &name, size_t width, size_t height, double scale = -1.0);
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, const std::vector<wxBitmap> &bmps) { return this->insert(name, &bmps.front(), &bmps.front() + bmps.size()); }
// wxBitmap* insert(const std::string &name, const wxBitmap *begin, const wxBitmap *end);
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, const std::vector<wxBitmap> &bmps) { return this->insert(name, &bmps.front(), &bmps.front() + bmps.size()); }
wxBitmap* insert(const std::string &name, const wxBitmap *begin, const wxBitmap *end);
wxBitmap* insert_raw_rgba(const std::string &bitmap_key, unsigned width, unsigned height, const unsigned char *raw_data, const bool grayscale = false);
// BBS: support resize by fill border (scale_in_center)
@ -50,28 +41,19 @@ public:
// And makes replases befor parsing
// replace_map containes old_value->new_value
static NSVGimage* nsvgParseFromFileWithReplace(const char* filename, const char* units, float dpi, const std::map<std::string, std::string>& replaces);
// Gets a data from SVG file and makes replases
// replace_map containes old_value->new_value
static void nsvgGetDataFromFileWithReplace(const char* filename, std::string& data_str, const std::map<std::string, std::string>& replaces);
wxBitmapBundle* from_svg(const std::string& bitmap_name, unsigned target_width, unsigned target_height, const bool dark_mode, const std::string& new_color = "");
wxBitmapBundle* from_png(const std::string& bitmap_name, unsigned width, unsigned height);
// Load svg from resources/icons. bitmap_key is given without the .svg suffix. SVG will be rasterized to provided height/width.
wxBitmap* load_svg(const std::string &bitmap_key, unsigned width = 0, unsigned height = 0, const bool grayscale = false, const bool dark_mode = false, const std::string& new_color = "", const float scale_in_center = 0.f);
// wxBitmap mksolid(size_t width, size_t height, unsigned char r, unsigned char g, unsigned char b, unsigned char transparency, bool suppress_scaling = false, size_t border_width = 0, bool dark_mode = false);
// wxBitmap mksolid(size_t width, size_t height, const unsigned char rgb[3], bool suppress_scaling = false, size_t border_width = 0, bool dark_mode = false) { return mksolid(width, height, rgb[0], rgb[1], rgb[2], wxALPHA_OPAQUE, suppress_scaling, border_width, dark_mode); }
// wxBitmap mksolid(size_t width, size_t height, const ColorRGB& rgb, bool suppress_scaling = false, size_t border_width = 0, bool dark_mode = false) { return mksolid(width, height, rgb.r_uchar(), rgb.g_uchar(), rgb.b_uchar(), wxALPHA_OPAQUE, suppress_scaling, border_width, dark_mode); }
// wxBitmap mkclear(size_t width, size_t height) { return mksolid(width, height, 0, 0, 0, wxALPHA_TRANSPARENT, true, 0); }
wxBitmapBundle mksolid(size_t width, size_t height, unsigned char r, unsigned char g, unsigned char b, unsigned char transparency, size_t border_width = 0, bool dark_mode = false);
wxBitmapBundle* mksolid_bndl(size_t width, size_t height, const std::string& color = std::string(), size_t border_width = 0, bool dark_mode = false);
wxBitmapBundle* mkclear_bndl(size_t width, size_t height) { return mksolid_bndl(width, height); }
wxBitmap mksolid(size_t width, size_t height, unsigned char r, unsigned char g, unsigned char b, unsigned char transparency, bool suppress_scaling = false, size_t border_width = 0, bool dark_mode = false);
wxBitmap mksolid(size_t width, size_t height, const unsigned char rgb[3], bool suppress_scaling = false, size_t border_width = 0, bool dark_mode = false) { return mksolid(width, height, rgb[0], rgb[1], rgb[2], wxALPHA_OPAQUE, suppress_scaling, border_width, dark_mode); }
wxBitmap mksolid(size_t width, size_t height, const ColorRGB& rgb, bool suppress_scaling = false, size_t border_width = 0, bool dark_mode = false) { return mksolid(width, height, rgb.r_uchar(), rgb.g_uchar(), rgb.b_uchar(), wxALPHA_OPAQUE, suppress_scaling, border_width, dark_mode); }
wxBitmap mkclear(size_t width, size_t height) { return mksolid(width, height, 0, 0, 0, wxALPHA_TRANSPARENT); }
static bool parse_color(const std::string& scolor, unsigned char* rgb_out);
static bool parse_color4(const std::string& scolor, unsigned char* rgba_out);
private:
std::map<std::string, wxBitmap*> m_map;
std::map<std::string, wxBitmapBundle*> m_bndl_map;
double m_gs = 0.2; // value, used for image.ConvertToGreyscale(m_gs, m_gs, m_gs)
double m_scale = 1.0; // value, used for correct scaling of SVG icons on Retina display
};

View file

@ -54,6 +54,17 @@ using Slic3r::GUI::format_wxstr;
namespace Slic3r {
namespace GUI {
/* For PresetComboBox we use bitmaps that are created from images that are already scaled appropriately for Retina
* (Contrary to the intuition, the `scale` argument for Bitmap's constructor doesn't mean
* "please scale this to such and such" but rather
* "the wxImage is already sized for backing scale such and such". )
* Unfortunately, the constructor changes the size of wxBitmap too.
* Thus We need to use unscaled size value for bitmaps that we use
* to avoid scaled size of control items.
* For this purpose control drawing methods and
* control size calculation methods (virtual) are overridden.
**/
BitmapComboBox::BitmapComboBox(wxWindow* parent,
wxWindowID id/* = wxID_ANY*/,
const wxString& value/* = wxEmptyString*/,
@ -79,6 +90,72 @@ BitmapComboBox::~BitmapComboBox()
{
}
#ifdef __APPLE__
bool BitmapComboBox::OnAddBitmap(const wxBitmap& bitmap)
{
if (bitmap.IsOk())
{
// we should use scaled! size values of bitmap
int width = (int)bitmap.GetScaledWidth();
int height = (int)bitmap.GetScaledHeight();
if (m_usedImgSize.x < 0)
{
// If size not yet determined, get it from this image.
m_usedImgSize.x = width;
m_usedImgSize.y = height;
// Adjust control size to vertically fit the bitmap
wxWindow* ctrl = GetControl();
ctrl->InvalidateBestSize();
wxSize newSz = ctrl->GetBestSize();
wxSize sz = ctrl->GetSize();
if (newSz.y > sz.y)
ctrl->SetSize(sz.x, newSz.y);
else
DetermineIndent();
}
wxCHECK_MSG(width == m_usedImgSize.x && height == m_usedImgSize.y,
false,
"you can only add images of same size");
return true;
}
return false;
}
void BitmapComboBox::OnDrawItem(wxDC& dc,
const wxRect& rect,
int item,
int flags) const
{
const wxBitmap& bmp = *(static_cast<wxBitmap*>(m_bitmaps[item]));
if (bmp.IsOk())
{
// we should use scaled! size values of bitmap
wxCoord w = bmp.GetScaledWidth();
wxCoord h = bmp.GetScaledHeight();
const int imgSpacingLeft = 4;
// Draw the image centered
dc.DrawBitmap(bmp,
rect.x + (m_usedImgSize.x - w) / 2 + imgSpacingLeft,
rect.y + (rect.height - h) / 2,
true);
}
wxString text = GetString(item);
if (!text.empty())
dc.DrawText(text,
rect.x + m_imgAreaWidth + 1,
rect.y + (rect.height - dc.GetCharHeight()) / 2);
}
#endif
#ifdef _WIN32
int BitmapComboBox::Append(const wxString& item)
@ -89,11 +166,18 @@ int BitmapComboBox::Append(const wxString& item)
//2. But then set width to 0 value for no using of bitmap left and right spacing
//3. Set this empty bitmap to the at list one item and BitmapCombobox will be recreated correct
wxBitmapBundle bitmap = *get_empty_bmp_bundle(1, 16);
wxBitmap bitmap(1, int(1.6 * wxGetApp().em_unit() + 1));
{
// bitmap.SetWidth(0); is depricated now
// so, use next code
bitmap.UnShare();// AllocExclusive();
bitmap.GetGDIImageData()->m_width = 0;
}
OnAddBitmap(bitmap);
const int n = wxComboBox::Append(item);
if (n != wxNOT_FOUND)
DoSetItemBitmap(n, bitmap);
return n;
}

View file

@ -29,13 +29,28 @@ BitmapComboBox(wxWindow* parent,
#ifdef _WIN32
int Append(const wxString& item);
#endif
int Append(const wxString& item, const wxBitmapBundle& bitmap)
int Append(const wxString& item, const wxBitmap& bitmap)
{
return wxBitmapComboBox::Append(item, bitmap);
}
protected:
#ifdef __APPLE__
/* For PresetComboBox we use bitmaps that are created from images that are already scaled appropriately for Retina
* (Contrary to the intuition, the `scale` argument for Bitmap's constructor doesn't mean
* "please scale this to such and such" but rather
* "the wxImage is already sized for backing scale such and such". )
* Unfortunately, the constructor changes the size of wxBitmap too.
* Thus We need to use unscaled size value for bitmaps that we use
* to avoid scaled size of control items.
* For this purpose control drawing methods and
* control size calculation methods (virtual) are overridden.
**/
bool OnAddBitmap(const wxBitmap& bitmap) override;
void OnDrawItem(wxDC& dc, const wxRect& rect, int item, int flags) const override;
#endif
#ifdef _WIN32
bool MSWOnDraw(WXDRAWITEMSTRUCT* item) override;
void DrawBackground_(wxDC& dc, const wxRect& rect, int WXUNUSED(item), int flags) const;

View file

@ -102,9 +102,9 @@ void MObjectPanel::doRender(wxDC& dc)
if (m_state == PrinterState::IN_LAN) { dwbitmap = m_printer_in_lan; }
// dc.DrawCircle(left, size.y / 2, 3);
dc.DrawBitmap(dwbitmap.get_bitmap(), wxPoint(left, (size.y - dwbitmap.GetSize().y) / 2));
dc.DrawBitmap(dwbitmap.bmp(), wxPoint(left, (size.y - dwbitmap.GetBmpSize().y) / 2));
left += dwbitmap.GetSize().x + 8;
left += dwbitmap.GetBmpSize().x + 8;
dc.SetFont(Label::Body_13);
dc.SetBackgroundMode(wxTRANSPARENT);
dc.SetTextForeground(StateColor::darkModeColorFor(SELECT_MACHINE_GREY900));
@ -242,7 +242,7 @@ void SelectMObjectPopup::Popup(wxWindow* WXUNUSED(focus))
if (wxGetApp().is_user_login()) {
if (!get_print_info_thread) {
get_print_info_thread = new boost::thread(Slic3r::create_thread([this, token = std::weak_ptr(m_token)] {
get_print_info_thread = new boost::thread(Slic3r::create_thread([this, token = std::weak_ptr<int>(m_token)] {
NetworkAgent* agent = wxGetApp().getAgent();
unsigned int http_code;
std::string body;
@ -716,4 +716,4 @@ CalibrationPanel::~CalibrationPanel() {
delete m_refresh_timer;
}
}}
}}

View file

@ -371,7 +371,7 @@ CaliPageCaption::CaliPageCaption(wxWindow* parent, CalibMode cali_mode,
auto top_sizer = new wxBoxSizer(wxVERTICAL);
auto caption_sizer = new wxBoxSizer(wxHORIZONTAL);
m_prev_btn = new ScalableButton(this, wxID_ANY, "cali_page_caption_prev",
wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER, 30);
wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER, true, 30);
m_prev_btn->SetBackgroundColour(*wxWHITE);
caption_sizer->Add(m_prev_btn, 0, wxALIGN_CENTER | wxRIGHT, FromDIP(10));
@ -382,7 +382,7 @@ CaliPageCaption::CaliPageCaption(wxWindow* parent, CalibMode cali_mode,
caption_sizer->Add(title_text, 0, wxALIGN_CENTER | wxRIGHT, FromDIP(10));
m_help_btn = new ScalableButton(this, wxID_ANY, "cali_page_caption_help",
wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER, 30);
wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER, true, 30);
m_help_btn->Hide();
m_help_btn->SetBackgroundColour(*wxWHITE);
caption_sizer->Add(m_help_btn, 0, wxALIGN_CENTER);
@ -472,12 +472,12 @@ void CaliPageCaption::show_help_icon(bool show)
void CaliPageCaption::on_sys_color_changed()
{
m_prev_btn->sys_color_changed();
m_prev_btn->msw_rescale();
}
void CaliPageCaption::msw_rescale()
{
m_prev_btn->sys_color_changed();
m_prev_btn->msw_rescale();
}
CaliPageStepGuide::CaliPageStepGuide(wxWindow* parent, wxArrayString steps,
@ -593,7 +593,7 @@ PAPageHelpPanel::PAPageHelpPanel(wxWindow* parent, bool ground_panel, wxWindowID
wxBoxSizer* help_text_sizer = new wxBoxSizer(wxHORIZONTAL);
auto help_text = new Label(this, _L("You could change the Flow Dynamics Calibration Factor in material editing"));
help_text->SetFont(Label::Body_14);
m_help_btn = new ScalableButton(this, wxID_ANY, "cali_page_caption_help", wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER, 24);
m_help_btn = new ScalableButton(this, wxID_ANY, "cali_page_caption_help", wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER, false, 24);
m_help_btn->SetBackgroundColour(m_help_btn->GetParent()->GetBackgroundColour());
help_text_sizer->Add(help_text, 0, wxALIGN_CENTER | wxLEFT, left_align_padding);
help_text_sizer->Add(m_help_btn, 0, wxALIGN_CENTER | wxLEFT, FromDIP(8));
@ -611,8 +611,8 @@ PAPageHelpPanel::PAPageHelpPanel(wxWindow* parent, bool ground_panel, wxWindowID
void PAPageHelpPanel::msw_rescale()
{
m_help_btn->sys_color_changed();
m_bmp.sys_color_changed();
m_help_btn->msw_rescale();
m_bmp.msw_rescale();
m_img->SetBitmap(m_bmp.bmp());
}

View file

@ -448,7 +448,7 @@ CalibrationPresetPage::CalibrationPresetPage(
void CalibrationPresetPage::msw_rescale()
{
CalibrationWizardPage::msw_rescale();
m_ams_sync_button->sys_color_changed();
m_ams_sync_button->msw_rescale();
m_virtual_tray_comboBox->msw_rescale();
for (auto& comboBox : m_filament_comboBox_list) {
comboBox->msw_rescale();
@ -458,7 +458,7 @@ void CalibrationPresetPage::msw_rescale()
void CalibrationPresetPage::on_sys_color_changed()
{
CalibrationWizardPage::on_sys_color_changed();
m_ams_sync_button->sys_color_changed();
m_ams_sync_button->msw_rescale();
}
void CalibrationPresetPage::create_selection_panel(wxWindow* parent)
@ -507,7 +507,7 @@ void CalibrationPresetPage::create_selection_panel(wxWindow* parent)
filament_for_text->SetFont(Label::Head_14);
filament_for_title_sizer->Add(filament_for_text, 0, wxALIGN_CENTER);
filament_for_title_sizer->AddSpacer(FromDIP(25));
m_ams_sync_button = new ScalableButton(parent, wxID_ANY, "ams_fila_sync", wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER, 18);
m_ams_sync_button = new ScalableButton(parent, wxID_ANY, "ams_fila_sync", wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER, false, 18);
m_ams_sync_button->SetBackgroundColour(*wxWHITE);
m_ams_sync_button->SetToolTip(_L("Synchronize filament list from AMS"));
filament_for_title_sizer->Add(m_ams_sync_button, 0, wxALIGN_CENTER);

View file

@ -470,8 +470,8 @@ CameraItem::CameraItem(wxWindow *parent, std::string normal, std::string hover)
CameraItem::~CameraItem() {}
void CameraItem::msw_rescale() {
m_bitmap_normal.sys_color_changed();
m_bitmap_hover.sys_color_changed();
m_bitmap_normal.msw_rescale();
m_bitmap_hover.msw_rescale();
}
void CameraItem::on_enter_win(wxMouseEvent &evt)
@ -519,9 +519,9 @@ void CameraItem::render(wxDC &dc)
void CameraItem::doRender(wxDC &dc)
{
if (m_hover) {
dc.DrawBitmap(m_bitmap_hover.get_bitmap(), wxPoint((GetSize().x - m_bitmap_hover.GetSize().x) / 2, (GetSize().y - m_bitmap_hover.GetSize().y) / 2));
dc.DrawBitmap(m_bitmap_hover.bmp(), wxPoint((GetSize().x - m_bitmap_hover.GetBmpSize().x) / 2, (GetSize().y - m_bitmap_hover.GetBmpSize().y) / 2));
} else {
dc.DrawBitmap(m_bitmap_normal.get_bitmap(), wxPoint((GetSize().x - m_bitmap_normal.GetSize().x) / 2, (GetSize().y - m_bitmap_normal.GetSize().y) / 2));
dc.DrawBitmap(m_bitmap_normal.bmp(), wxPoint((GetSize().x - m_bitmap_normal.GetBmpSize().x) / 2, (GetSize().y - m_bitmap_normal.GetBmpSize().y) / 2));
}
}

View file

@ -277,7 +277,6 @@ void ConfigManipulation::update_print_fff_config(DynamicPrintConfig* config, con
sparse_infill_density == 0 &&
! config->opt_bool("enable_support") &&
config->opt_int("enforce_support_layers") == 0 &&
config->opt_bool("ensure_vertical_shell_thickness") &&
! config->opt_bool("detect_thin_wall") &&
! config->opt_bool("overhang_reverse") &&
config->opt_enum<TimelapseType>("timelapse_type") == TimelapseType::tlTraditional))
@ -305,7 +304,6 @@ void ConfigManipulation::update_print_fff_config(DynamicPrintConfig* config, con
new_conf.set_key_value("sparse_infill_density", new ConfigOptionPercent(0));
new_conf.set_key_value("enable_support", new ConfigOptionBool(false));
new_conf.set_key_value("enforce_support_layers", new ConfigOptionInt(0));
new_conf.set_key_value("ensure_vertical_shell_thickness", new ConfigOptionBool(true));
new_conf.set_key_value("detect_thin_wall", new ConfigOptionBool(false));
new_conf.set_key_value("overhang_reverse", new ConfigOptionBool(false));
new_conf.set_key_value("timelapse_type", new ConfigOptionEnum<TimelapseType>(tlTraditional));
@ -326,6 +324,30 @@ void ConfigManipulation::update_print_fff_config(DynamicPrintConfig* config, con
}
is_msg_dlg_already_exist = false;
}
if (config->opt_bool("alternate_extra_wall") && config->opt_bool("ensure_vertical_shell_thickness"))
{
wxString msg_text = _(L("Alternate extra wall only works with ensure vertical shell thickness disabled. "));
if (is_global_config)
msg_text += "\n\n" + _(L("Change these settings automatically? \n"
"Yes - Disable ensure vertical shell thickness and enable alternate extra wall\n"
"No - Dont use alternate extra wall"));
MessageDialog dialog(m_msg_dlg_parent, msg_text, "",
wxICON_WARNING | (is_global_config ? wxYES | wxNO : wxOK));
DynamicPrintConfig new_conf = *config;
auto answer = dialog.ShowModal();
if (!is_global_config || answer == wxID_YES) {
new_conf.set_key_value("ensure_vertical_shell_thickness", new ConfigOptionBool(false));
new_conf.set_key_value("alternate_extra_wall", new ConfigOptionBool(true));
}
else {
new_conf.set_key_value("ensure_vertical_shell_thickness", new ConfigOptionBool(true));
new_conf.set_key_value("alternate_extra_wall", new ConfigOptionBool(false));
}
apply(config, &new_conf);
}
// BBS
int filament_cnt = wxGetApp().preset_bundle->filament_presets.size();
@ -506,7 +528,7 @@ void ConfigManipulation::toggle_print_fff_options(DynamicPrintConfig *config, co
bool has_spiral_vase = config->opt_bool("spiral_mode");
toggle_line("spiral_mode_smooth", has_spiral_vase);
toggle_line("spiral_mode_max_xy_smoothing", config->opt_bool("spiral_mode_smooth"));
toggle_line("spiral_mode_max_xy_smoothing", has_spiral_vase && config->opt_bool("spiral_mode_smooth"));
bool has_top_solid_infill = config->opt_int("top_shell_layers") > 0;
bool has_bottom_solid_infill = config->opt_int("bottom_shell_layers") > 0;
bool has_solid_infill = has_top_solid_infill || has_bottom_solid_infill;
@ -690,8 +712,6 @@ void ConfigManipulation::toggle_print_fff_options(DynamicPrintConfig *config, co
toggle_line("make_overhang_printable_angle", have_make_overhang_printable);
toggle_line("make_overhang_printable_hole_size", have_make_overhang_printable);
toggle_line("exclude_object", gcflavor == gcfKlipper);
toggle_line("min_width_top_surface",config->opt_bool("only_one_wall_top"));
for (auto el : { "hole_to_polyhole_threshold", "hole_to_polyhole_twisted" })

View file

@ -1499,7 +1499,7 @@ ConfigWizardIndex::ConfigWizardIndex(wxWindow *parent)
#ifndef __WXOSX__
SetDoubleBuffered(true);// SetDoubleBuffered exists on Win and Linux/GTK, but is missing on OSX
#endif //__WXOSX__
SetMinSize(bg.GetSize());
SetMinSize(bg.bmp().GetSize());
const wxSize size = GetTextExtent("m");
em_w = size.x;
@ -1626,8 +1626,8 @@ void ConfigWizardIndex::on_paint(wxPaintEvent & evt)
wxPaintDC dc(this);
const auto bullet_w = bullet_black.GetWidth();
const auto bullet_h = bullet_black.GetHeight();
const auto bullet_w = bullet_black.bmp().GetSize().GetWidth();
const auto bullet_h = bullet_black.bmp().GetSize().GetHeight();
const int yoff_icon = bullet_h < em_h ? (em_h - bullet_h) / 2 : 0;
const int yoff_text = bullet_h > em_h ? (bullet_h - em_h) / 2 : 0;
const int yinc = item_height();
@ -1640,10 +1640,10 @@ void ConfigWizardIndex::on_paint(wxPaintEvent & evt)
unsigned x = em_w/2 + item.indent * em_w;
if (i == item_active || (item_hover >= 0 && i == (size_t)item_hover)) {
dc.DrawBitmap(bullet_blue.get_bitmap(), x, y + yoff_icon, false);
dc.DrawBitmap(bullet_blue.bmp(), x, y + yoff_icon, false);
}
else if (i < item_active) { dc.DrawBitmap(bullet_black.get_bitmap(), x, y + yoff_icon, false); }
else if (i > item_active) { dc.DrawBitmap(bullet_white.get_bitmap(), x, y + yoff_icon, false); }
else if (i < item_active) { dc.DrawBitmap(bullet_black.bmp(), x, y + yoff_icon, false); }
else if (i > item_active) { dc.DrawBitmap(bullet_white.bmp(), x, y + yoff_icon, false); }
x += + bullet_w + em_w/2;
const auto text_size = dc.GetTextExtent(item.label);
@ -1655,9 +1655,9 @@ void ConfigWizardIndex::on_paint(wxPaintEvent & evt)
}
//draw logo
if (int y = size.y - bg.GetHeight(); y>=0) {
dc.DrawBitmap(bg.get_bitmap(), 0, y, false);
index_width = std::max(index_width, bg.GetWidth() + em_w / 2);
if (int y = size.y - bg.GetBmpHeight(); y>=0) {
dc.DrawBitmap(bg.bmp(), 0, y, false);
index_width = std::max(index_width, bg.GetBmpWidth() + em_w / 2);
}
if (GetMinSize().x < index_width) {
@ -1689,12 +1689,12 @@ void ConfigWizardIndex::msw_rescale()
em_w = size.x;
em_h = size.y;
bg.sys_color_changed();
SetMinSize(bg.GetSize());
bg.msw_rescale();
SetMinSize(bg.bmp().GetSize());
bullet_black.sys_color_changed();
bullet_blue.sys_color_changed();
bullet_white.sys_color_changed();
bullet_black.msw_rescale();
bullet_blue.msw_rescale();
bullet_white.msw_rescale();
Refresh();
}

View file

@ -510,7 +510,7 @@ private:
ssize_t item_hover;
size_t last_page;
int item_height() const { return std::max(bullet_black.GetHeight(), em_w) + em_w; }
int item_height() const { return std::max(bullet_black.bmp().GetSize().GetHeight(), em_w) + em_w; }
void on_paint(wxPaintEvent &evt);
void on_mouse_move(wxMouseEvent &evt);

View file

@ -13,6 +13,7 @@
#include "FileHelp.hpp"
#include "Tab.hpp"
#include "MainFrame.hpp"
#include "libslic3r_version.h"
#define NAME_OPTION_COMBOBOX_SIZE wxSize(FromDIP(200), FromDIP(24))
#define FILAMENT_PRESET_COMBOBOX_SIZE wxSize(FromDIP(300), FromDIP(24))
@ -179,7 +180,7 @@ static bool delete_filament_preset_by_name(std::string delete_preset_name, std::
return true;
}
static std::string get_curr_time()
static std::string get_curr_time(const char* format = "%Y_%m_%d_%H_%M_%S")
{
std::chrono::system_clock::time_point now = std::chrono::system_clock::now();
@ -187,7 +188,7 @@ static std::string get_curr_time()
std::tm local_time = *std::localtime(&time);
std::ostringstream time_stream;
time_stream << std::put_time(&local_time, "%Y_%m_%d_%H_%M_%S");
time_stream << std::put_time(&local_time, format);
std::string current_time = time_stream.str();
return current_time;
@ -195,11 +196,12 @@ static std::string get_curr_time()
static std::string get_curr_timestmp()
{
std::time_t currentTime = std::time(nullptr);
std::ostringstream oss;
oss << currentTime;
std::string timestampString = oss.str();
return timestampString;
return get_curr_time("%Y%m%d%H%M%S");
// std::time_t currentTime = std::time(nullptr);
// std::ostringstream oss;
// oss << currentTime;
// std::string timestampString = oss.str();
// return timestampString;
}
static void get_filament_compatible_printer(Preset* preset, vector<std::string>& printers)
@ -1474,9 +1476,9 @@ wxBoxSizer *CreatePrinterPresetDialog::create_step_switch_item()
{
wxBoxSizer *step_switch_sizer = new wxBoxSizer(wxVERTICAL);
std::string wiki_url = "https://wiki.bambulab.com/en/software/bambu-studio/3rd-party-printer-profile";
wxHyperlinkCtrl *m_download_hyperlink = new wxHyperlinkCtrl(this, wxID_ANY, _L("wiki"), wiki_url, wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE);
step_switch_sizer->Add(m_download_hyperlink, 0, wxRIGHT | wxALIGN_RIGHT, FromDIP(5));
// std::string wiki_url = "https://wiki.bambulab.com/en/software/bambu-studio/3rd-party-printer-profile";
// wxHyperlinkCtrl *m_download_hyperlink = new wxHyperlinkCtrl(this, wxID_ANY, _L("wiki"), wiki_url, wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE);
// step_switch_sizer->Add(m_download_hyperlink, 0, wxRIGHT | wxALIGN_RIGHT, FromDIP(5));
wxBoxSizer *horizontal_sizer = new wxBoxSizer(wxHORIZONTAL);
wxPanel * step_switch_panel = new wxPanel(this);
@ -3266,8 +3268,8 @@ void CreatePresetSuccessfulDialog::on_dpi_changed(const wxRect &suggested_rect)
ExportConfigsDialog::ExportConfigsDialog(wxWindow *parent)
: DPIDialog(parent ? parent : nullptr, wxID_ANY, _L("Export Configs"), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX)
{
m_exprot_type.preset_bundle = _L("Printer config bundle(.bbscfg)");
m_exprot_type.filament_bundle = _L("Filament bundle(.bbsflmt)");
m_exprot_type.preset_bundle = _L("Printer config bundle(.orca_printer)");
m_exprot_type.filament_bundle = _L("Filament bundle(.orca_filament)");
m_exprot_type.printer_preset = _L("Printer presets(.zip)");
m_exprot_type.filament_preset = _L("Filament presets(.zip)");
m_exprot_type.process_preset = _L("Process presets(.zip)");
@ -3407,49 +3409,7 @@ std::string ExportConfigsDialog::initial_file_path(const wxString &path, const s
std::string export_path = into_u8(path);
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << "initial file path and path is:" << export_path << " and sub path is: " << sub_file_path;
boost::filesystem::path printer_export_path = (boost::filesystem::path(export_path) / sub_file_path).make_preferred();
if (boost::filesystem::exists(printer_export_path)) {
MessageDialog dlg(this, wxString::Format(_L("The '%s' folder already exists in the current directory. Do you want to clear it and rebuild it.\nIf not, a time suffix will be "
"added, and you can modify the name after creation."), sub_file_path), wxString(SLIC3R_APP_FULL_NAME) + " - " + _L("Info"), wxYES_NO | wxYES_DEFAULT | wxCENTRE);
int res = dlg.ShowModal();
if (wxID_YES == res) {
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << "Same path exists, delete and need to rebuild, and path is: " << printer_export_path.string();
try {
boost::filesystem::remove_all(printer_export_path);
} catch (...) {
MessageDialog dlg(this, _L(wxString::Format("The file: %s \nin the directory may have been opened by another program. \nPlease close it and try again.",
encode_path(printer_export_path.string().c_str()))),
wxString(SLIC3R_APP_FULL_NAME) + " - " + _L("Info"),
wxYES | wxYES_DEFAULT | wxCENTRE);
dlg.ShowModal();
return "initial_failed";
}
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << "delete path";
boost::filesystem::create_directories(printer_export_path);
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << "create path";
export_path = printer_export_path.string();
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << "Same path exists, delete and rebuild, and path is: " << export_path;
} else if (wxID_NO == res) {
export_path = printer_export_path.string();
std::string export_path_with_time;
boost::filesystem::path *printer_export_path_with_time = nullptr;
do {
if (printer_export_path_with_time) {
delete printer_export_path_with_time;
printer_export_path_with_time = nullptr;
}
export_path_with_time = export_path + " " + get_curr_time();
printer_export_path_with_time = new boost::filesystem::path(export_path_with_time);
} while (boost::filesystem::exists(*printer_export_path_with_time));
export_path = export_path_with_time;
boost::filesystem::create_directories(*printer_export_path_with_time);
if (printer_export_path_with_time) {
delete printer_export_path_with_time;
printer_export_path_with_time = nullptr;
}
} else {
return "";
}
} else {
if (!boost::filesystem::exists(printer_export_path)) {
boost::filesystem::create_directories(printer_export_path);
export_path = printer_export_path.string();
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << "Same path exists, delete and rebuild, and path is: " << export_path;
@ -3519,7 +3479,7 @@ wxBoxSizer *ExportConfigsDialog::create_export_config_item(wxWindow *parent)
radioBoxSizer->Add(create_radio_item(m_exprot_type.preset_bundle, parent, wxEmptyString, m_export_type_btns), 0, wxEXPAND | wxALL, 0);
radioBoxSizer->Add(0, 0, 0, wxTOP, FromDIP(6));
wxStaticText *static_export_printer_preset_bundle_text = new wxStaticText(parent, wxID_ANY, _L("Printer and all the filament&process presets that belongs to the printer. \nCan be shared with others."), wxDefaultPosition, wxDefaultSize);
wxStaticText *static_export_printer_preset_bundle_text = new wxStaticText(parent, wxID_ANY, _L("Printer and all the filament&&process presets that belongs to the printer. \nCan be shared with others."), wxDefaultPosition, wxDefaultSize);
static_export_printer_preset_bundle_text->SetFont(Label::Body_12);
static_export_printer_preset_bundle_text->SetForegroundColour(wxColour("#6B6B6B"));
radioBoxSizer->Add(static_export_printer_preset_bundle_text, 0, wxEXPAND | wxLEFT, FromDIP(22));
@ -3707,7 +3667,7 @@ void ExportConfigsDialog::select_curr_radiobox(std::vector<std::pair<RadioBox *,
ExportConfigsDialog::ExportCase ExportConfigsDialog::archive_preset_bundle_to_file(const wxString &path)
{
std::string export_path = initial_file_path(path, "Printer config bundle");
std::string export_path = initial_file_path(path, "");
if (export_path.empty() || "initial_failed" == export_path) return ExportCase::EXPORT_CANCEL;
BOOST_LOG_TRIVIAL(info) << "Export printer preset bundle";
@ -3717,19 +3677,11 @@ ExportConfigsDialog::ExportCase ExportConfigsDialog::archive_preset_bundle_to_fi
std::string printer_preset_name_ = printer_preset->name;
json bundle_structure;
NetworkAgent *agent = wxGetApp().getAgent();
std::string clock = get_curr_timestmp();
if (agent) {
bundle_structure["user_name"] = agent->get_user_name();
bundle_structure["user_id"] = agent->get_user_id();
bundle_structure["version"] = agent->get_version();
bundle_structure["bundle_id"] = agent->get_user_id() + "_" + printer_preset_name_ + "_" + clock;
} else {
bundle_structure["user_name"] = "";
bundle_structure["user_id"] = "";
bundle_structure["version"] = "";
bundle_structure["bundle_id"] = "offline_" + printer_preset_name_ + "_" + clock;
}
bundle_structure["user_name"] = "";
bundle_structure["user_id"] = "";
bundle_structure["version"] = SoftFever_VERSION;
bundle_structure["bundle_id"] = printer_preset_name_ + "_" + clock;
bundle_structure["bundle_type"] = "printer config bundle";
bundle_structure["printer_preset_name"] = printer_preset_name_;
json printer_config = json::array();
@ -3737,21 +3689,21 @@ ExportConfigsDialog::ExportCase ExportConfigsDialog::archive_preset_bundle_to_fi
json process_configs = json::array();
mz_zip_archive zip_archive;
mz_bool status = initial_zip_archive(zip_archive, export_path + "/" + printer_preset->name + ".bbscfg");
mz_bool status = initial_zip_archive(zip_archive, export_path + "/" + printer_preset->name + ".orca_printer");
if (MZ_FALSE == status) {
BOOST_LOG_TRIVIAL(info) << "Failed to initialize ZIP archive";
return ExportCase::INITIALIZE_FAIL;
}
boost::filesystem::path pronter_file_path = boost::filesystem::path(printer_preset->file);
std::string preset_path = pronter_file_path.make_preferred().string();
boost::filesystem::path printer_file_path = boost::filesystem::path(printer_preset->file);
std::string preset_path = printer_file_path.make_preferred().string();
if (preset_path.empty()) {
BOOST_LOG_TRIVIAL(info) << "Export printer preset: " << printer_preset->name << " skip because of the preset file path is empty.";
continue;
}
// Add a file to the ZIP file
std::string printer_config_file_name = "printer/" + pronter_file_path.filename().string();
std::string printer_config_file_name = "printer/" + printer_file_path.filename().string();
status = mz_zip_writer_add_file(&zip_archive, printer_config_file_name.c_str(), encode_path(preset_path.c_str()).c_str(), NULL, 0, MZ_DEFAULT_COMPRESSION);
//status = mz_zip_writer_add_mem(&zip_archive, ("printer/" + printer_preset->name + ".json").c_str(), json_contents, strlen(json_contents), MZ_DEFAULT_COMPRESSION);
if (MZ_FALSE == status) {
@ -3831,7 +3783,7 @@ ExportConfigsDialog::ExportCase ExportConfigsDialog::archive_preset_bundle_to_fi
ExportConfigsDialog::ExportCase ExportConfigsDialog::archive_filament_bundle_to_file(const wxString &path)
{
std::string export_path = initial_file_path(path, "Filament bundle");
std::string export_path = initial_file_path(path, "");
if (export_path.empty() || "initial_failed" == export_path) return ExportCase::EXPORT_CANCEL;
BOOST_LOG_TRIVIAL(info) << "Export filament preset bundle";
@ -3840,25 +3792,17 @@ ExportConfigsDialog::ExportCase ExportConfigsDialog::archive_filament_bundle_to_
std::string filament_name = checkbox_filament_name.second;
json bundle_structure;
NetworkAgent *agent = wxGetApp().getAgent();
std::string clock = get_curr_timestmp();
if (agent) {
bundle_structure["user_name"] = agent->get_user_name();
bundle_structure["user_id"] = agent->get_user_id();
bundle_structure["version"] = agent->get_version();
bundle_structure["bundle_id"] = agent->get_user_id() + "_" + filament_name + "_" + clock;
} else {
bundle_structure["user_name"] = "";
bundle_structure["user_id"] = "";
bundle_structure["version"] = "";
bundle_structure["bundle_id"] = "offline_" + filament_name + "_" + clock;
}
bundle_structure["user_name"] = "";
bundle_structure["user_id"] = "";
bundle_structure["version"] = SoftFever_VERSION;
bundle_structure["bundle_id"] = filament_name + "_" + clock;
bundle_structure["bundle_type"] = "filament config bundle";
bundle_structure["filament_name"] = filament_name;
std::unordered_map<std::string, json> vendor_structure;
mz_zip_archive zip_archive;
mz_bool status = initial_zip_archive(zip_archive, export_path + "/" + filament_name + ".bbsflmt");
mz_bool status = initial_zip_archive(zip_archive, export_path + "/" + filament_name + ".orca_filament");
if (MZ_FALSE == status) {
BOOST_LOG_TRIVIAL(info) << "Failed to initialize ZIP archive";
return ExportCase::INITIALIZE_FAIL;
@ -4070,7 +4014,7 @@ wxBoxSizer *ExportConfigsDialog::create_button_item(wxWindow* parent)
return;
}
wxDirDialog dlg(this, _L("Choose a directory"), from_u8(wxGetApp().app_config->get_last_dir()), wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST);
wxDirDialog dlg(this, _L("Choose a directory"), "", wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST);
wxString path;
if (dlg.ShowModal() == wxID_OK) path = dlg.GetPath();
ExportCase export_case = ExportCase::EXPORT_CANCEL;

View file

@ -1378,9 +1378,13 @@ void MachineObject::parse_status(int flag)
}
if (!is_support_p1s_plus) {
is_support_p1s_plus = ((flag >> 27) & 0x1) != 0;
}
auto supported_plus = ((flag >> 27) & 0x1) != 0;
auto installed_plus = ((flag >> 26) & 0x1) != 0;
if (installed_plus && supported_plus) {
is_support_p1s_plus = true;
}
}
sdcard_state = MachineObject::SdcardState((flag >> 8) & 0x11);
@ -4064,12 +4068,6 @@ int MachineObject::parse_json(std::string payload)
} else if (jj["command"].get<std::string>() == "gcode_line") {
//ack of gcode_line
BOOST_LOG_TRIVIAL(debug) << "parse_json, ack of gcode_line = " << j.dump(4);
if (m_agent && is_studio_cmd(sequence_id)) {
json t;
t["dev_id"] = this->dev_id;
t["signal"] = this->wifi_signal;
m_agent->track_event("ack_cmd_gcode_line", t.dump());
}
} else if (jj["command"].get<std::string>() == "project_prepare") {
//ack of project file
BOOST_LOG_TRIVIAL(info) << "parse_json, ack of project_prepare = " << j.dump(4);
@ -4082,13 +4080,6 @@ int MachineObject::parse_json(std::string payload)
} else if (jj["command"].get<std::string>() == "project_file") {
//ack of project file
BOOST_LOG_TRIVIAL(debug) << "parse_json, ack of project_file = " << j.dump(4);
if (m_agent && is_studio_cmd(sequence_id)) {
json t;
t["dev_id"] = this->dev_id;
t["signal"] = this->wifi_signal;
m_agent->track_event("ack_cmd_project_file", t.dump());
}
std::string result;
if (jj.contains("result")) {
result = jj["result"].get<std::string>();

View file

@ -46,8 +46,8 @@ void DragCanvas::set_shape_list(const std::vector<std::string>& colors, const st
m_dragshape_list.clear();
for (int i = 0; i < order.size(); i++) {
wxBitmap bmp = get_extruder_color_icon(colors[order[i] - 1], std::to_string(order[i]), SHAPE_SIZE, SHAPE_SIZE)->GetBitmapFor(m_parent);
DragShape* shape = new DragShape(bmp, order[i]);
wxBitmap* bmp = get_extruder_color_icon(colors[order[i] - 1], std::to_string(order[i]), SHAPE_SIZE, SHAPE_SIZE);
DragShape* shape = new DragShape(*bmp, order[i]);
m_dragshape_list.push_back(shape);
}

View file

@ -33,15 +33,6 @@ wxIMPLEMENT_DYNAMIC_CLASS(DataViewBitmapText, wxObject)
IMPLEMENT_VARIANT_OBJECT(DataViewBitmapText)
static wxSize get_size(const wxBitmap& icon)
{
#ifdef __WIN32__
return icon.GetSize();
#else
return icon.GetScaledSize();
#endif
}
// ---------------------------------------------------------
// BitmapTextRenderer
// ---------------------------------------------------------
@ -133,7 +124,11 @@ bool BitmapTextRenderer::Render(wxRect rect, wxDC *dc, int state)
const wxBitmap& icon = m_value.GetBitmap();
if (icon.IsOk())
{
wxSize icon_sz = get_size(icon);
#ifdef __APPLE__
wxSize icon_sz = icon.GetScaledSize();
#else
wxSize icon_sz = icon.GetSize();
#endif
dc->DrawBitmap(icon, rect.x, rect.y + (rect.height - icon_sz.y) / 2);
xoffset = icon_sz.x + 4;
}
@ -275,12 +270,11 @@ bool BitmapChoiceRenderer::Render(wxRect rect, wxDC* dc, int state)
const wxBitmap& icon = m_value.GetBitmap();
if (icon.IsOk())
{
wxSize icon_sz = get_size(icon);
dc->DrawBitmap(icon, rect.x, rect.y + (rect.height - icon_sz.GetHeight()) / 2);
// xoffset = icon_sz.GetWidth() + 4;
dc->DrawBitmap(icon, rect.x, rect.y + (rect.height - icon.GetHeight()) / 2);
// xoffset = icon.GetWidth() + 4;
if (rect.height == 0)
rect.height = icon_sz.GetHeight();
rect.height = icon.GetHeight();
}
#ifdef _WIN32
@ -311,7 +305,7 @@ wxWindow* BitmapChoiceRenderer::CreateEditorCtrl(wxWindow* parent, wxRect labelR
if (can_create_editor_ctrl && !can_create_editor_ctrl())
return nullptr;
std::vector<wxBitmapBundle*> icons = get_extruder_color_icons();
std::vector<wxBitmap*> icons = get_extruder_color_icons();
if (icons.empty())
return nullptr;

View file

@ -1132,7 +1132,7 @@ void Choice::BUILD()
auto icon_name = "param_" + m_opt.enum_values[i];
if (boost::filesystem::exists(image_path / (icon_name + ".svg"))) {
ScalableBitmap bm(temp, icon_name, 24);
temp->Append(_(el), bm.get_bitmap());
temp->Append(_(el), bm.bmp());
} else {
temp->Append(_(el));
}
@ -1534,7 +1534,7 @@ void Choice::msw_rescale()
auto icon_name = "param_" + m_opt.enum_values[i];
if (boost::filesystem::exists(image_path / (icon_name + ".svg"))) {
ScalableBitmap bm(window, icon_name, 24);
temp->SetItemBitmap(i, bm.get_bitmap());
temp->SetItemBitmap(i, bm.bmp());
}
++i;
}

View file

@ -4485,11 +4485,14 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
}
};
auto append_headers = [&imgui](const std::vector<std::pair<std::string, float>>& title_offsets) {
auto append_headers = [&imgui, window_padding](const std::vector<std::pair<std::string, float>>& title_offsets) {
for (size_t i = 0; i < title_offsets.size(); i++) {
ImGui::SameLine(title_offsets[i].second);
imgui.bold_text(title_offsets[i].first);
}
// Ensure right padding
ImGui::SameLine();
ImGui::Dummy({window_padding, 1});
ImGui::Separator();
};
@ -4507,8 +4510,12 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
offsets.push_back(max_width(title_columns[0].second, title_columns[0].first, extra_size) + 3.0f * style.ItemSpacing.x);
for (size_t i = 1; i < title_columns.size() - 1; i++)
offsets.push_back(offsets.back() + max_width(title_columns[i].second, title_columns[i].first) + style.ItemSpacing.x);
if (title_columns.back().first == _u8L("Display"))
offsets.back() = ImGui::GetWindowWidth() - ImGui::CalcTextSize(_u8L("Display").c_str()).x - ImGui::GetFrameHeight() / 2 - 2 * window_padding;
if (title_columns.back().first == _u8L("Display")) {
const auto preferred_offset = ImGui::GetWindowWidth() - ImGui::CalcTextSize(_u8L("Display").c_str()).x - ImGui::GetFrameHeight() / 2 - 2 * window_padding;
if (preferred_offset > offsets.back()) {
offsets.back() = preferred_offset;
}
}
float average_col_width = ImGui::GetWindowWidth() / static_cast<float>(title_columns.size());
std::vector<float> ret;
@ -4586,8 +4593,9 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
if (it == m_print_statistics.used_filaments_per_role.end())
return std::make_pair(0.0, 0.0);
double koef = imperial_units ? 1000.0 / GizmoObjectManipulation::in_to_mm : 1.0;
return std::make_pair(it->second.first * koef, it->second.second);
double koef = imperial_units ? GizmoObjectManipulation::in_to_mm / 1000.0 : 1.0;
double unit_conver = imperial_units ? GizmoObjectManipulation::oz_to_g : 1;
return std::make_pair(it->second.first / koef, it->second.second / unit_conver);
};
// get used filament (meters and grams) from used volume in respect to the active extruder
@ -4664,6 +4672,8 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
std::vector<std::string> times;
std::string travel_time;
std::vector<std::string> percents;
std::vector<std::string> used_filaments_length;
std::vector<std::string> used_filaments_weight;
std::string travel_percent;
std::vector<double> model_used_filaments_m;
std::vector<double> model_used_filaments_g;
@ -4707,9 +4717,12 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
else
percent > 0.001 ? ::sprintf(buffer, "%.1f%%", percent * 100) : ::sprintf(buffer, "<0.1%%");
percents.push_back(buffer);
//auto [model_used_filament_m, model_used_filament_g] = used_filament_per_role(role);
//model_used_filaments_m.push_back(model_used_filament_m);
//model_used_filaments_g.push_back(model_used_filament_g);
auto [model_used_filament_m, model_used_filament_g] = used_filament_per_role(role);
::sprintf(buffer, imperial_units ? "%.2f in" : "%.2f m", model_used_filament_m);
used_filaments_length.push_back(buffer);
::sprintf(buffer, imperial_units ? "%.2f oz" : "%.2f g", model_used_filament_g);
used_filaments_weight.push_back(buffer);
}
}
@ -4724,8 +4737,8 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
travel_percent = buffer;
}
offsets = calculate_offsets({ {_u8L("Line Type"), labels}, {_u8L("Time"), times}, {_u8L("Percent"), percents}, {_u8L("Display"), {""}}}, icon_size);
append_headers({{_u8L("Line Type"), offsets[0]}, {_u8L("Time"), offsets[1]}, {_u8L("Percent"), offsets[2]}, {_u8L("Display"), offsets[3]}});
offsets = calculate_offsets({ {_u8L("Line Type"), labels}, {_u8L("Time"), times}, {_u8L("Percent"), percents}, {"", used_filaments_length}, {"", used_filaments_weight}, {_u8L("Display"), {""}}}, icon_size);
append_headers({{_u8L("Line Type"), offsets[0]}, {_u8L("Time"), offsets[1]}, {_u8L("Percent"), offsets[2]}, {_u8L("Used filament"), offsets[3]}, {_u8L("Display"), offsets[5]}});
break;
}
case EViewType::Height: { imgui.title(_u8L("Layer Height (mm)")); break; }
@ -4877,7 +4890,9 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
std::vector<std::pair<std::string, float>> columns_offsets;
columns_offsets.push_back({ labels[i], offsets[0] });
columns_offsets.push_back({ times[i], offsets[1] });
columns_offsets.push_back({ percents[i], offsets[2] });
columns_offsets.push_back({percents[i], offsets[2]});
columns_offsets.push_back({used_filaments_length[i], offsets[3]});
columns_offsets.push_back({used_filaments_weight[i], offsets[4]});
append_item(EItemType::Rect, Extrusion_Role_Colors[static_cast<unsigned int>(role)], columns_offsets,
true, visible, [this, role, visible]() {
m_extrusions.role_visibility_flags = visible ? m_extrusions.role_visibility_flags & ~(1 << role) : m_extrusions.role_visibility_flags | (1 << role);

View file

@ -28,8 +28,8 @@
#define STB_DXT_IMPLEMENTATION
#include "stb_dxt/stb_dxt.h"
#include <nanosvg/nanosvg.h>
#include <nanosvg/nanosvgrast.h>
#include "nanosvg/nanosvg.h"
#include "nanosvg/nanosvgrast.h"
#include "libslic3r/Utils.hpp"
#include "GUI_App.hpp"

View file

@ -4,6 +4,7 @@
#include "GUI_ObjectList.hpp"
#include "GUI_Factories.hpp"
#include "format.hpp"
#include "libslic3r_version.h"
// Localization headers: include libslic3r version first so everything in this file
// uses the slic3r/GUI version (the macros will take precedence over the functions).
@ -369,7 +370,7 @@ public:
// See https://github.com/wxWidgets/wxWidgets/blob/master/src/msw/font.cpp
// void wxNativeFontInfo::SetFractionalPointSize(float pointSizeNew)
wxNativeFontInfo nfi= *font.GetNativeFontInfo();
float pointSizeNew = wxDisplay(this).GetScaleFactor() * scale * font.GetPointSize();
float pointSizeNew = scale * font.GetPointSize();
nfi.lf.lfHeight = nfi.GetLogFontHeightAtPPI(pointSizeNew, get_dpi_for_window(this));
nfi.pointSize = pointSizeNew;
font = wxFont(nfi);
@ -2107,6 +2108,9 @@ void GUI_App::init_app_config()
if (!boost::filesystem::exists(data_dir_path)){
boost::filesystem::create_directory(data_dir_path);
}
// Change current dirtory of application
chdir(encode_path((Slic3r::data_dir() + "/log").c_str()).c_str());
} else {
m_datadir_redefined = true;
}
@ -4290,7 +4294,8 @@ Semver get_version(const std::string& str, const std::regex& regexp) {
void GUI_App::check_new_version_sf(bool show_tips, int by_user)
{
AppConfig* app_config = wxGetApp().app_config;
auto version_check_url = app_config->version_check_url();
bool check_stable_only = app_config->get_bool("check_stable_update_only");
auto version_check_url = app_config->version_check_url(check_stable_only);
Http::get(version_check_url)
.on_error([&](std::string body, std::string error, unsigned http_status) {
(void)body;
@ -4298,25 +4303,22 @@ void GUI_App::check_new_version_sf(bool show_tips, int by_user)
error);
})
.timeout_connect(1)
.on_complete([this,by_user](std::string body, unsigned http_status) {
.on_complete([this,by_user, check_stable_only](std::string body, unsigned http_status) {
// Http response OK
if (http_status != 200)
return;
try {
boost::trim(body);
// SoftFever: parse github release, ported from SS
// Orca: parse github release, inspired by SS
boost::property_tree::ptree root;
std::stringstream json_stream(body);
boost::property_tree::read_json(json_stream, root);
bool i_am_pre = false;
// at least two number, use '.' as separator. can be followed by -Az23 for prereleased and +Az42 for
// metadata
std::regex matcher("[0-9]+\\.[0-9]+(\\.[0-9]+)*(-[A-Za-z0-9]+)?(\\+[A-Za-z0-9]+)?");
Semver current_version = get_version(SoftFever_VERSION, matcher);
Semver current_version = get_version(SoftFever_VERSION, matcher);
Semver best_pre(1, 0, 0);
Semver best_release(1, 0, 0);
std::string best_pre_url;
@ -4324,56 +4326,73 @@ void GUI_App::check_new_version_sf(bool show_tips, int by_user)
std::string best_release_content;
std::string best_pre_content;
const std::regex reg_num("([0-9]+)");
std::string tag = root.get<std::string>("tag_name");
if (tag[0] == 'v')
tag.erase(0, 1);
for (std::regex_iterator it = std::sregex_iterator(tag.begin(), tag.end(), reg_num);
it != std::sregex_iterator(); ++it) {
}
Semver tag_version = get_version(tag, matcher);
if (current_version == tag_version)
i_am_pre = root.get<bool>("prerelease");
if (root.get<bool>("prerelease")) {
if (best_pre < tag_version) {
best_pre = tag_version;
best_pre_url = root.get<std::string>("html_url");
best_pre_content = root.get<std::string>("body");
best_pre.set_prerelease("Preview");
}
if (check_stable_only) {
std::string tag = root.get<std::string>("tag_name");
if (tag[0] == 'v')
tag.erase(0, 1);
for (std::regex_iterator it = std::sregex_iterator(tag.begin(), tag.end(), reg_num); it != std::sregex_iterator(); ++it) {}
Semver tag_version = get_version(tag, matcher);
if (root.get<bool>("prerelease")) {
if (best_pre < tag_version) {
best_pre = tag_version;
best_pre_url = root.get<std::string>("html_url");
best_pre_content = root.get<std::string>("body");
best_pre.set_prerelease("Preview");
}
} else {
if (best_release < tag_version) {
best_release = tag_version;
best_release_url = root.get<std::string>("html_url");
best_release_content = root.get<std::string>("body");
}
}
} else {
if (best_release < tag_version) {
best_release = tag_version;
best_release_url = root.get<std::string>("html_url");
best_release_content = root.get<std::string>("body");
}
for (auto json_version : root) {
std::string tag = json_version.second.get<std::string>("tag_name");
if (tag[0] == 'v')
tag.erase(0, 1);
for (std::regex_iterator it = std::sregex_iterator(tag.begin(), tag.end(), reg_num); it != std::sregex_iterator();
++it) {}
Semver tag_version = get_version(tag, matcher);
if (json_version.second.get<bool>("prerelease")) {
if (best_pre < tag_version) {
best_pre = tag_version;
best_pre_url = json_version.second.get<std::string>("html_url");
best_pre_content = json_version.second.get<std::string>("body");
best_pre.set_prerelease("Preview");
}
} else {
if (best_release < tag_version) {
best_release = tag_version;
best_release_url = json_version.second.get<std::string>("html_url");
best_release_content = json_version.second.get<std::string>("body");
}
}
}
}
// if release is more recent than beta, use release anyway
if (best_pre < best_release) {
best_pre = best_release;
best_pre_url = best_release_url;
best_pre_content = best_release_content;
best_pre = best_release;
best_pre_url = best_release_url;
best_pre_content = best_release_content;
}
// if we're the most recent, don't do anything
if ((i_am_pre ? best_pre : best_release) <= current_version) {
if (by_user != 0)
this->no_new_version();
return;
if ((check_stable_only ? best_release : best_pre) <= current_version) {
if (by_user != 0)
this->no_new_version();
return;
}
// BOOST_LOG_TRIVIAL(info) << format("Got %1% online version: `%2%`. Sending to GUI thread...",
// SLIC3R_APP_NAME, i_am_pre ? best_pre.to_string(): best_release.to_string());
version_info.url = i_am_pre ? best_pre_url : best_release_url;
version_info.version_str = i_am_pre ? best_pre.to_string() : best_release.to_string_sf();
version_info.description = i_am_pre ? best_pre_content : best_release_content;
version_info.url = check_stable_only ? best_release_url : best_pre_url;
version_info.version_str = check_stable_only ? best_release.to_string_sf() : best_pre.to_string();
version_info.description = check_stable_only ? best_release_content : best_pre_content;
version_info.force_upgrade = false;
wxCommandEvent *evt = new wxCommandEvent(EVT_SLIC3R_VERSION_ONLINE);
evt->SetString((i_am_pre ? best_pre : best_release).to_string());
wxCommandEvent* evt = new wxCommandEvent(EVT_SLIC3R_VERSION_ONLINE);
evt->SetString((check_stable_only ? best_release : best_pre).to_string());
GUI::wxGetApp().QueueEvent(evt);
} catch (...) {
}
} catch (...) {}
})
.perform();
}
@ -4591,8 +4610,7 @@ void GUI_App::sync_preset(Preset* preset)
if (http_code >= 400) {
result = 0;
updated_info = "hold";
}
else
} else
result = -1;
}
}
@ -4614,8 +4632,7 @@ void GUI_App::sync_preset(Preset* preset)
auto update_time_str = values_map[BBL_JSON_KEY_UPDATE_TIME];
if (!update_time_str.empty())
update_time = std::atoll(update_time_str.c_str());
}
else {
} else {
BOOST_LOG_TRIVIAL(trace) << "[sync_preset]create: request_setting_id failed, http code "<<http_code;
// do not post new preset this time if http code >= 400
if (http_code >= 400) {
@ -4625,12 +4642,10 @@ void GUI_App::sync_preset(Preset* preset)
else
result = -1;
}
}
else {
} else {
BOOST_LOG_TRIVIAL(trace) << "[sync_preset]create: can not generate differed preset";
}
}
else if (preset->sync_info.compare("update") == 0) {
} else if (preset->sync_info.compare("update") == 0) {
if (!setting_id.empty()) {
int ret = preset_bundle->get_differed_values_to_update(*preset, values_map);
if (!ret) {
@ -4724,7 +4739,7 @@ void GUI_App::start_sync_user_preset(bool with_progress_dlg)
cancelFn = [this, dlg]() {
return m_is_closing || dlg->WasCanceled();
};
finishFn = [this, userid = m_agent->get_user_id(), dlg, t = std::weak_ptr(m_user_sync_token)](bool ok) {
finishFn = [this, userid = m_agent->get_user_id(), dlg, t = std::weak_ptr<int>(m_user_sync_token)](bool ok) {
CallAfter([=]{
dlg->Destroy();
if (ok && m_agent && t.lock() == m_user_sync_token && userid == m_agent->get_user_id()) reload_settings();
@ -4732,7 +4747,7 @@ void GUI_App::start_sync_user_preset(bool with_progress_dlg)
};
}
else {
finishFn = [this, userid = m_agent->get_user_id(), t = std::weak_ptr(m_user_sync_token)](bool ok) {
finishFn = [this, userid = m_agent->get_user_id(), t = std::weak_ptr<int>(m_user_sync_token)](bool ok) {
CallAfter([=] {
if (ok && m_agent && t.lock() == m_user_sync_token && userid == m_agent->get_user_id()) reload_settings();
});
@ -4740,7 +4755,7 @@ void GUI_App::start_sync_user_preset(bool with_progress_dlg)
}
m_sync_update_thread = Slic3r::create_thread(
[this, progressFn, cancelFn, finishFn, t = std::weak_ptr(m_user_sync_token)] {
[this, progressFn, cancelFn, finishFn, t = std::weak_ptr<int>(m_user_sync_token)] {
// get setting list, update setting list
std::string version = preset_bundle->get_vendor_profile_version(PresetBundle::BBL_BUNDLE).to_string();
int ret = m_agent->get_setting_list2(version, [this](auto info) {
@ -5028,7 +5043,7 @@ bool GUI_App::select_language()
// 3) new_language_info->CanonicalName is a safe bet. It points to a valid dictionary name.
app_config->set("language", new_language_info->CanonicalName.ToUTF8().data());
return true;
}
}
}
return false;
@ -5936,18 +5951,15 @@ void GUI_App::MacOpenFiles(const wxArrayString &fileNames)
input_files.push_back(non_gcode_files[i]);
}
this->plater()->load_files(input_files);
}
else {
} else {
for (size_t i = 0; i < files.size(); ++i) {
this->init_params->input_files.emplace_back(files[i]);
}
}
}
else {
} else {
if (m_post_initialized) {
this->plater()->load_gcode(gcode_files.front());
}
else {
} else {
this->init_params->input_gcode = true;
this->init_params->input_files = { into_u8(gcode_files.front()) };
}
@ -6296,8 +6308,7 @@ void GUI_App::gcode_thumbnails_debug()
width = 0;
height = 0;
rows.clear();
}
else if (reading_image)
} else if (reading_image)
row += gcode_line.substr(2);
}
}

View file

@ -267,13 +267,14 @@ std::map<std::string, std::string> SettingsFactory::CATEGORY_ICON =
// BBS: remove SLA categories
};
wxBitmapBundle* SettingsFactory::get_category_bitmap(const std::string& category_name)
wxBitmap SettingsFactory::get_category_bitmap(const std::string& category_name, bool menu_bmp)
{
if (CATEGORY_ICON.find(category_name) == CATEGORY_ICON.end())
return get_bmp_bundle("empty");
return get_bmp_bundle(CATEGORY_ICON.at(category_name));
return wxNullBitmap;
return create_scaled_bitmap(CATEGORY_ICON.at(category_name));
}
//-------------------------------------
// MenuFactory
//-------------------------------------
@ -434,30 +435,31 @@ static void create_freq_settings_popupmenu(wxMenu* menu, const bool is_object_se
}
}
std::vector<wxBitmapBundle*> MenuFactory::get_volume_bitmaps()
std::vector<wxBitmap> MenuFactory::get_volume_bitmaps()
{
std::vector<wxBitmapBundle*> volume_bmps;
std::vector<wxBitmap> volume_bmps;
volume_bmps.reserve(ADD_VOLUME_MENU_ITEMS.size());
for (const auto& item : ADD_VOLUME_MENU_ITEMS)
volume_bmps.push_back(get_bmp_bundle(item.second));
for (const auto& item : ADD_VOLUME_MENU_ITEMS) {
volume_bmps.push_back(create_scaled_bitmap(item.second));
}
return volume_bmps;
}
std::vector<wxBitmapBundle*> MenuFactory::get_text_volume_bitmaps()
std::vector<wxBitmap> MenuFactory::get_text_volume_bitmaps()
{
std::vector<wxBitmapBundle*> volume_bmps;
std::vector<wxBitmap> volume_bmps;
volume_bmps.reserve(TEXT_VOLUME_ICONS.size());
for (const auto& item : TEXT_VOLUME_ICONS)
volume_bmps.push_back(get_bmp_bundle(item.second));
volume_bmps.push_back(create_scaled_bitmap(item.second));
return volume_bmps;
}
std::vector<wxBitmapBundle*> MenuFactory::get_svg_volume_bitmaps()
std::vector<wxBitmap> MenuFactory::get_svg_volume_bitmaps()
{
std::vector<wxBitmapBundle *> volume_bmps;
std::vector<wxBitmap> volume_bmps;
volume_bmps.reserve(SVG_VOLUME_ICONS.size());
for (const auto &item : SVG_VOLUME_ICONS)
volume_bmps.push_back(get_bmp_bundle(item.second));
volume_bmps.push_back(create_scaled_bitmap(item.second));
return volume_bmps;
}
@ -496,8 +498,27 @@ wxMenu* MenuFactory::append_submenu_add_generic(wxMenu* menu, ModelVolumeType ty
sub_menu->AppendSeparator();
}
for (auto &item : {L("Cube"), L("Cylinder"), L("Sphere"), L("Cone"), L("Disc"), L("Torus")}) {
append_menu_item(
sub_menu, wxID_ANY, _(item), "",
[type, item](wxCommandEvent &) {
obj_list()->load_generic_subobject(item, type);
},
"", menu);
}
append_menu_item_add_text(sub_menu, type);
append_menu_item_add_svg(sub_menu, type);
return sub_menu;
}
// Orca: add submenu for adding handy models
wxMenu* MenuFactory::append_submenu_add_handy_model(wxMenu* menu, ModelVolumeType type) {
auto sub_menu = new wxMenu;
for (auto &item : {L("Orca Cube"), L("3DBenchy"), L("Autodesk FDM Test"),
L("Voron Cube")}) {
L("Voron Cube"), L("Stanford Bunny")}) {
append_menu_item(
sub_menu, wxID_ANY, _(item), "",
[type, item](wxCommandEvent &) {
@ -511,6 +532,8 @@ wxMenu* MenuFactory::append_submenu_add_generic(wxMenu* menu, ModelVolumeType ty
file_name = "ksr_fdmtest_v4.stl";
else if (file_name == L("Voron Cube"))
file_name = "Voron_Design_Cube_v7.stl";
else if (file_name == L("Stanford Bunny"))
file_name = "Stanford_Bunny.stl";
else
return;
input_files.push_back(
@ -521,22 +544,9 @@ wxMenu* MenuFactory::append_submenu_add_generic(wxMenu* menu, ModelVolumeType ty
"", menu);
}
append_menu_item_add_text(sub_menu, type);
append_menu_item_add_svg(sub_menu, type);
sub_menu->AppendSeparator();
for (auto &item : {L("Cube"), L("Cylinder"), L("Sphere"), L("Cone")}) {
append_menu_item(
sub_menu, wxID_ANY, _(item), "",
[type, item](wxCommandEvent &) {
obj_list()->load_generic_subobject(item, type);
},
"", menu);
}
return sub_menu;
}
static void append_menu_itemm_add_(const wxString& name, GLGizmosManager::EType gizmo_type, wxMenu *menu, ModelVolumeType type, bool is_submenu_item) {
auto add_ = [type, gizmo_type](const wxCommandEvent & /*unnamed*/) {
const GLCanvas3D *canvas = plater()->canvas3D();
@ -690,7 +700,7 @@ wxMenuItem* MenuFactory::append_menu_item_settings(wxMenu* menu_)
// Add full settings list
auto menu_item = new wxMenuItem(menu, wxID_ANY, menu_name);
menu_item->SetBitmap(*get_bmp_bundle("cog"));
menu_item->SetBitmap(create_scaled_bitmap("cog"));
menu_item->SetSubMenu(create_settings_popupmenu(menu, is_object_settings, item));
return menu->Append(menu_item);
@ -839,7 +849,7 @@ void MenuFactory::append_menu_item_change_extruder(wxMenu* menu)
if (sels.IsEmpty())
return;
std::vector<wxBitmapBundle*> icons = get_extruder_color_icons(true);
std::vector<wxBitmap*> icons = get_extruder_color_icons(true);
wxMenu* extruder_selection_menu = new wxMenu();
const wxString& name = sels.Count() == 1 ? names[0] : names[1];
@ -860,7 +870,7 @@ void MenuFactory::append_menu_item_change_extruder(wxMenu* menu)
if (icon_idx >= 0 && icon_idx < icons.size()) {
append_menu_item(
extruder_selection_menu, wxID_ANY, item_name, "", [i](wxCommandEvent &) { obj_list()->set_extruder_for_selected_items(i); }, icons[icon_idx], menu,
extruder_selection_menu, wxID_ANY, item_name, "", [i](wxCommandEvent &) { obj_list()->set_extruder_for_selected_items(i); }, *icons[icon_idx], menu,
[is_active_extruder]() { return !is_active_extruder; }, m_parent);
} else {
append_menu_item(
@ -1163,12 +1173,17 @@ MenuFactory::MenuFactory()
void MenuFactory::create_default_menu()
{
wxMenu* sub_menu = append_submenu_add_generic(&m_default_menu, ModelVolumeType::INVALID);
wxMenu* sub_menu_primitives = append_submenu_add_generic(&m_default_menu, ModelVolumeType::INVALID);
wxMenu* sub_menu_handy = append_submenu_add_handy_model(&m_default_menu, ModelVolumeType::INVALID);
#ifdef __WINDOWS__
append_submenu(&m_default_menu, sub_menu, wxID_ANY, _L("Add Primitive"), "", "menu_add_part",
append_submenu(&m_default_menu, sub_menu_primitives, wxID_ANY, _L("Add Primitive"), "", "menu_add_part",
[]() {return true; }, m_parent);
append_submenu(&m_default_menu, sub_menu_handy, wxID_ANY, _L("Add Handy models"), "", "menu_add_part",
[]() {return true; }, m_parent);
#else
append_submenu(&m_default_menu, sub_menu, wxID_ANY, _L("Add Primitive"), "", "",
append_submenu(&m_default_menu, sub_menu_primitives, wxID_ANY, _L("Add Primitive"), "", "",
[]() {return true; }, m_parent);
append_submenu(&m_default_menu, sub_menu_handy, wxID_ANY, _L("Add Handy models"), "", "",
[]() {return true; }, m_parent);
#endif
@ -1452,13 +1467,18 @@ void MenuFactory::create_plate_menu()
// add shapes
menu->AppendSeparator();
wxMenu* sub_menu = append_submenu_add_generic(menu, ModelVolumeType::INVALID);
wxMenu* sub_menu_primitives = append_submenu_add_generic(menu, ModelVolumeType::INVALID);
wxMenu* sub_menu_handy = append_submenu_add_handy_model(menu, ModelVolumeType::INVALID);
#ifdef __WINDOWS__
append_submenu(menu, sub_menu, wxID_ANY, _L("Add Primitive"), "", "menu_add_part",
append_submenu(menu, sub_menu_primitives, wxID_ANY, _L("Add Primitive"), "", "menu_add_part",
[]() {return true; }, m_parent);
append_submenu(menu, sub_menu_handy, wxID_ANY, _L("Add Handy models"), "", "menu_add_part",
[]() {return true; }, m_parent);
#else
append_submenu(menu, sub_menu, wxID_ANY, _L("Add Primitive"), "", "",
append_submenu(menu, sub_menu_primitives, wxID_ANY, _L("Add Primitive"), "", "",
[]() {return true; }, m_parent);
append_submenu(menu, sub_menu_handy, wxID_ANY, _L("Add Handy models"), "", "",
[]() {return true; }, m_parent);
#endif
@ -1788,7 +1808,7 @@ void MenuFactory::append_menu_item_change_filament(wxMenu* menu)
return;
}
std::vector<wxBitmapBundle*> icons = get_extruder_color_icons(true);
std::vector<wxBitmap*> icons = get_extruder_color_icons(true);
if (icons.size() < filaments_cnt) {
BOOST_LOG_TRIVIAL(warning) << boost::format("Warning: icons size %1%, filaments_cnt=%2%")%icons.size()%filaments_cnt;
if (icons.size() <= 1)
@ -1828,9 +1848,8 @@ void MenuFactory::append_menu_item_change_filament(wxMenu* menu)
const wxString& item_name = (i == 0 ? _L("Default") : wxString::Format(_L("Filament %d"), i)) +
(is_active_extruder ? " (" + _L("current") + ")" : "");
//OcraftyoneTODO: determine if nullptr in place of icon causes issues
append_menu_item(extruder_selection_menu, wxID_ANY, item_name, "",
[i](wxCommandEvent&) { obj_list()->set_extruder_for_selected_items(i); }, i == 0 ? nullptr : icons[i - 1], menu,
[i](wxCommandEvent&) { obj_list()->set_extruder_for_selected_items(i); }, i == 0 ? wxNullBitmap : *icons[i - 1], menu,
[is_active_extruder]() { return !is_active_extruder; }, m_parent);
}
menu->Append(wxID_ANY, name, extruder_selection_menu, _L("Change Filament"));
@ -1940,7 +1959,7 @@ void MenuFactory::update_object_menu()
void MenuFactory::update_default_menu()
{
for (auto& name : { _L("Add Primitive") , _L("Show Labels") }) {
for (auto& name : { _L("Add Primitive") , _L("Add Handy models"), _L("Show Labels") }) {
const auto menu_item_id = m_default_menu.FindItem(name);
if (menu_item_id != wxNOT_FOUND)
m_default_menu.Destroy(menu_item_id);
@ -1948,6 +1967,12 @@ void MenuFactory::update_default_menu()
create_default_menu();
}
void MenuFactory::msw_rescale()
{
for (MenuWithSeparators* menu : { &m_object_menu, &m_sla_object_menu, &m_part_menu, &m_default_menu })
msw_rescale_menu(dynamic_cast<wxMenu*>(menu));
}
#ifdef _WIN32
// For this class is used code from stackoverflow:
// https://stackoverflow.com/questions/257288/is-it-possible-to-write-a-template-to-check-for-a-functions-existence
@ -1977,7 +2002,7 @@ static void update_menu_item_def_colors(T* item)
void MenuFactory::sys_color_changed()
{
for (MenuWithSeparators* menu : { &m_object_menu, &m_sla_object_menu, &m_part_menu, &m_default_menu }) {
sys_color_changed_menu(dynamic_cast<wxMenu *>(menu));// msw_rescale_menu updates just icons, so use it
msw_rescale_menu(dynamic_cast<wxMenu*>(menu));// msw_rescale_menu updates just icons, so use it
#ifdef _WIN32
// but under MSW we have to update item's bachground color
for (wxMenuItem* item : menu->GetMenuItems())
@ -1992,17 +2017,14 @@ void MenuFactory::sys_color_changed(wxMenuBar* menubar)
#if 0
for (size_t id = 0; id < menubar->GetMenuCount(); id++) {
wxMenu* menu = menubar->GetMenu(id);
sys_color_changed_menu(menu);
#ifndef __linux__
menu->SetupBitmaps();
msw_rescale_menu(menu);
#ifdef _WIN32
// but under MSW we have to update item's bachground color
for (wxMenuItem* item : menu->GetMenuItems())
update_menu_item_def_colors(item);
#endif
}
// menubar->Refresh();
#endif
menubar->Refresh();
#endif
}

View file

@ -40,7 +40,7 @@ struct SettingsFactory
static std::map<std::string, std::vector<SimpleSettingData>> OBJECT_CATEGORY_SETTINGS;
static std::map<std::string, std::vector<SimpleSettingData>> PART_CATEGORY_SETTINGS;
static wxBitmapBundle* get_category_bitmap(const std::string& category_name);
static wxBitmap get_category_bitmap(const std::string& category_name, bool menu_bmp = true);
static Bundle get_bundle(const DynamicPrintConfig* config, bool is_object_settings, bool is_layer_settings = false);
static std::vector<std::string> get_options(bool is_part);
//BBS: add api to get options for catogary
@ -51,9 +51,9 @@ struct SettingsFactory
class MenuFactory
{
public:
static std::vector<wxBitmapBundle*> get_volume_bitmaps();
static std::vector<wxBitmapBundle*> get_text_volume_bitmaps();
static std::vector<wxBitmapBundle*> get_svg_volume_bitmaps();
static std::vector<wxBitmap> get_volume_bitmaps();
static std::vector<wxBitmap> get_text_volume_bitmaps();
static std::vector<wxBitmap> get_svg_volume_bitmaps();
MenuFactory();
~MenuFactory() = default;
@ -62,6 +62,7 @@ public:
void update();
void update_object_menu();
void update_default_menu();
void msw_rescale();
void sys_color_changed();
static void sys_color_changed(wxMenuBar* menu_bar);
@ -124,6 +125,8 @@ private:
void create_bbl_assemble_part_menu();
wxMenu* append_submenu_add_generic(wxMenu* menu, ModelVolumeType type);
// Orca: add submenu for adding handy models
wxMenu* append_submenu_add_handy_model(wxMenu* menu, ModelVolumeType type);
void append_menu_item_add_text(wxMenu* menu, ModelVolumeType type, bool is_submenu_item = true);
void append_menu_item_add_svg(wxMenu *menu, ModelVolumeType type, bool is_submenu_item = true);
void append_menu_items_add_volume(wxMenu* menu);

View file

@ -248,14 +248,47 @@ void ObjectLayers::UpdateAndShow(const bool show)
void ObjectLayers::msw_rescale()
{
//Orca: deleted what PS commented out
m_bmp_delete.msw_rescale();
m_bmp_add.msw_rescale();
m_grid_sizer->SetHGap(wxGetApp().em_unit());
// rescale edit-boxes
const int cells_cnt = m_grid_sizer->GetCols() * m_grid_sizer->GetEffectiveRowsCount();
for (int i = 0; i < cells_cnt; ++i) {
const wxSizerItem* item = m_grid_sizer->GetItem(i);
if (item->IsWindow()) {
LayerRangeEditor* editor = dynamic_cast<LayerRangeEditor*>(item->GetWindow());
if (editor != nullptr)
editor->msw_rescale();
}
else if (item->IsSizer()) // case when we have editor with buttons
{
wxSizerItem* e_item = item->GetSizer()->GetItem(size_t(0)); // editor
if (e_item->IsWindow()) {
LayerRangeEditor* editor = dynamic_cast<LayerRangeEditor*>(e_item->GetWindow());
if (editor != nullptr)
editor->msw_rescale();
}
if (item->GetSizer()->GetItemCount() > 2) // if there are Add/Del buttons
for (size_t btn : {2, 3}) { // del_btn, add_btn
wxSizerItem* b_item = item->GetSizer()->GetItem(btn);
if (b_item->IsWindow()) {
auto button = dynamic_cast<PlusMinusButton*>(b_item->GetWindow());
if (button != nullptr)
button->msw_rescale();
}
}
}
}
m_grid_sizer->Layout();
}
void ObjectLayers::sys_color_changed()
{
m_bmp_delete.sys_color_changed();
m_bmp_add.sys_color_changed();
m_bmp_delete.msw_rescale();
m_bmp_add.msw_rescale();
// rescale edit-boxes
const int cells_cnt = m_grid_sizer->GetCols() * m_grid_sizer->GetEffectiveRowsCount();
@ -267,7 +300,7 @@ void ObjectLayers::sys_color_changed()
if (b_item && b_item->IsWindow()) {
auto button = dynamic_cast<PlusMinusButton*>(b_item->GetWindow());
if (button != nullptr)
button->sys_color_changed();
button->msw_rescale();
}
}
}

View file

@ -1368,11 +1368,12 @@ void ObjectList::extruder_editing()
if (!item || !(m_objects_model->GetItemType(item) & (itVolume | itObject)))
return;
wxRect rect = this->GetItemRect(item, GetColumn(colFilament));
wxPoint pos = rect.GetPosition();
pos.y -= 4;
wxSize size = rect.GetSize();
size.SetWidth(size.GetWidth() + 8);
const int column_width = GetColumn(colFilament)->GetWidth() + wxSystemSettings::GetMetric(wxSYS_VSCROLL_X) + 5;
wxPoint pos = this->get_mouse_position_in_control();
wxSize size = wxSize(column_width, -1);
pos.x = GetColumn(colName)->GetWidth() + GetColumn(colPrint)->GetWidth() + 5;
pos.y -= GetTextExtent("m").y;
apply_extruder_selector(&m_extruder_editor, this, "1", pos, size);
@ -2084,23 +2085,27 @@ static TriangleMesh create_mesh(const std::string& type_name, const BoundingBoxf
{
const double side = wxGetApp().plater()->canvas3D()->get_size_proportional_to_max_bed_size(0.1);
indexed_triangle_set mesh;
TriangleMesh mesh;
if (type_name == "Cube")
// Sitting on the print bed, left front front corner at (0, 0).
mesh = its_make_cube(side, side, side);
mesh = TriangleMesh(its_make_cube(side, side, side));
else if (type_name == "Cylinder")
// Centered around 0, sitting on the print bed.
// The cylinder has the same volume as the box above.
mesh = its_make_cylinder(0.5 * side, side);
mesh = TriangleMesh(its_make_cylinder(0.5 * side, side));
else if (type_name == "Sphere")
// Centered around 0, half the sphere below the print bed, half above.
// The sphere has the same volume as the box above.
mesh = its_make_sphere(0.5 * side, PI / 18);
mesh = TriangleMesh(its_make_sphere(0.5 * side, PI / 18));
else if (type_name == "Slab")
// Sitting on the print bed, left front front corner at (0, 0).
mesh = its_make_cube(bb.size().x() * 1.5, bb.size().y() * 1.5, bb.size().z() * 0.5);
mesh = TriangleMesh(its_make_cube(bb.size().x() * 1.5, bb.size().y() * 1.5, bb.size().z() * 0.5));
else if (type_name == "Cone")
mesh = its_make_cone(0.5 * side, side);
mesh = TriangleMesh(its_make_cone(0.5 * side, side));
else if (type_name == "Disc")
mesh.ReadSTLFile((Slic3r::resources_dir() + "/handy_models/helper_disk.stl").c_str(), true, nullptr);
else if (type_name == "Torus")
mesh.ReadSTLFile((Slic3r::resources_dir() + "/handy_models/torus.stl").c_str(), true, nullptr);
return TriangleMesh(mesh);
}
@ -3156,21 +3161,6 @@ bool ObjectList::can_merge_to_single_object() const
return (*m_objects)[obj_idx]->volumes.size() > 1;
}
wxPoint ObjectList::get_mouse_position_in_control() const
{
wxPoint pt = wxGetMousePosition() - this->GetScreenPosition();
#ifdef __APPLE__
// Workaround for OSX. From wxWidgets 3.1.6 Hittest doesn't respect to the header of wxDataViewCtrl
if (wxDataViewItem top_item = this->GetTopItem(); top_item.IsOk()) {
auto rect = this->GetItemRect(top_item, this->GetColumn(0));
pt.y -= rect.y;
}
#endif // __APPLE__
return pt;
}
bool ObjectList::can_mesh_boolean() const
{
int obj_idx = get_selected_obj_idx();
@ -5482,17 +5472,17 @@ void ObjectList::msw_rescale()
GetColumn(colSinking)->SetWidth(3 * em);
GetColumn(colEditing )->SetWidth( 3 * em);
// rescale/update existing items with bitmaps
m_objects_model->Rescale();
Layout();
}
void ObjectList::sys_color_changed()
{
wxGetApp().UpdateDVCDarkUI(this, true);
// rescale/update existing items with bitmaps
m_objects_model->UpdateBitmaps();
Layout();
msw_rescale();
if (m_objects_model) { m_objects_model->sys_color_changed(); }
}
@ -5529,12 +5519,6 @@ void GUI::ObjectList::OnStartEditing(wxDataViewEvent &event)
// Here the last active column is forgotten, so when leaving the editing mode, the next mouse click will not enter the editing mode of the newly selected column.
void ObjectList::OnEditingStarted(wxDataViewEvent &event)
{
// Orca: Automatically show drop down on editing start and finish editing when the combobox is closed
if (event.GetColumn() == colFilament) {
::ComboBox*c = static_cast<::ComboBox *>(event.GetDataViewColumn()->GetRenderer()->GetEditorCtrl());
c->ToggleDropDown();
c->Bind(wxEVT_COMBOBOX_CLOSEUP, [event](wxCommandEvent& evt){ event.GetDataViewColumn()->GetRenderer()->FinishEditing(); });
}
#ifdef __WXMSW__
m_last_selected_column = -1;
#else

View file

@ -319,7 +319,7 @@ public:
void delete_all_connectors_for_selection();
void delete_all_connectors_for_object(int obj_idx);
wxPoint get_mouse_position_in_control() const;
wxPoint get_mouse_position_in_control() const { return wxGetMousePosition() - this->GetScreenPosition(); }
int get_selected_obj_idx() const;
ModelConfig& get_item_config(const wxDataViewItem& item) const;

View file

@ -112,7 +112,7 @@ bool ObjectSettings::update_settings_list()
btn->SetToolTip(_(L("Remove parameter")));
btn->SetBitmapFocus(m_bmp_delete_focus.bmp());
btn->SetBitmapCurrent(m_bmp_delete_focus.bmp());
btn->SetBitmapHover(m_bmp_delete_focus.bmp());
btn->Bind(wxEVT_BUTTON, [opt_key, config, this](wxEvent &event) {
wxGetApp().plater()->take_snapshot(from_u8((boost::format("Delete Option %s") % opt_key).str()).ToStdString());
@ -146,7 +146,7 @@ bool ObjectSettings::update_settings_list()
return;
ctrl->SetBitmap_(m_bmp_delete);
ctrl->SetBitmapFocus(m_bmp_delete_focus.bmp());
ctrl->SetBitmapCurrent(m_bmp_delete_focus.bmp());
ctrl->SetBitmapHover(m_bmp_delete_focus.bmp());
};
const bool is_extruders_cat = cat.first == "Extruders";
@ -415,13 +415,21 @@ void ObjectSettings::UpdateAndShow(const bool show)
#endif
}
void ObjectSettings::msw_rescale()
{
#if !NEW_OBJECT_SETTING
m_bmp_delete.msw_rescale();
m_bmp_delete_focus.msw_rescale();
for (auto group : m_og_settings)
group->msw_rescale();
#endif
}
void ObjectSettings::sys_color_changed()
{
#if !NEW_OBJECT_SETTING
m_og->sys_color_changed(); // not in old msw_rescale. is it needed?
// moved from old msw_rescale
m_bmp_delete.sys_color_changed();
m_bmp_delete_focus.sys_color_changed();
m_og->sys_color_changed();
for (auto group : m_og_settings)
group->sys_color_changed();

View file

@ -68,6 +68,7 @@ public:
bool add_missed_options(ModelConfig *config_to, const DynamicPrintConfig &config_from);
void update_config_values(ModelConfig *config);
void UpdateAndShow(const bool show);
void msw_rescale();
void sys_color_changed();
};

View file

@ -77,7 +77,7 @@ void GridCellIconRenderer::Draw(wxGrid& grid,
table->m_icon_row_height = grid.GetRowSize(row);
table->m_icon_col_width = grid.GetColSize(col);
//}
wxBitmap bitmap = table->get_undo_bitmap().GetBitmapFor(dc.GetWindow());
wxBitmap& bitmap = table->get_undo_bitmap();
int bitmap_width = bitmap.GetWidth();
int bitmap_height = bitmap.GetHeight();
int offset_x = (table->m_icon_col_width - bitmap_width)/2;
@ -125,7 +125,7 @@ GridCellIconRenderer *GridCellIconRenderer::Clone() const
GridCellFilamentsEditor::GridCellFilamentsEditor(const wxArrayString& choices,
bool allowOthers,
std::vector<wxBitmapBundle*>* bitmaps)
std::vector<wxBitmap*>* bitmaps)
: wxGridCellChoiceEditor(choices, allowOthers), m_icons(bitmaps)
{
}
@ -133,7 +133,7 @@ GridCellFilamentsEditor::GridCellFilamentsEditor(const wxArrayString& choices,
GridCellFilamentsEditor::GridCellFilamentsEditor(size_t count,
const wxString choices[],
bool allowOthers,
std::vector<wxBitmapBundle*>* bitmaps)
std::vector<wxBitmap*>* bitmaps)
: wxGridCellChoiceEditor(count, choices, allowOthers), m_icons(bitmaps)
{
}
@ -159,14 +159,13 @@ void GridCellFilamentsEditor::Create(wxWindow* parent,
if ( !m_allowOthers )
style |= wxCB_READONLY;
::ComboBox *bitmap_combo = new ComboBox(parent, id, wxEmptyString,
wxDefaultPosition, wxSize(get_preferred_size(*((*m_icons)[0]), wxGetApp().mainframe).GetWidth() + 10, -1),
0, nullptr, CB_NO_DROP_ICON | CB_NO_TEXT | wxCB_READONLY); //Unsure
wxDefaultPosition, wxSize(((*m_icons)[0])->GetWidth() + 10, -1), 0, nullptr, CB_NO_DROP_ICON | CB_NO_TEXT | wxCB_READONLY);
if (m_icons) {
int array_count = m_choices.GetCount();
int icon_count = m_icons->size();
for (int i = 0; i < array_count; i++)
{
wxBitmapBundle* bitmap = (i < icon_count) ? (*m_icons)[i] : (*m_icons)[0];
wxBitmap* bitmap = (i < icon_count) ? (*m_icons)[i] : (*m_icons)[0];
bitmap_combo->Append(m_choices[i], *bitmap);
}
}
@ -240,9 +239,6 @@ void GridCellFilamentsEditor::BeginEdit(int row, int col, wxGrid* grid)
Combo()->SetFocus();
// Orca: Show dropdown on editing start
Combo()->ToggleDropDown();
#ifdef __WXOSX_COCOA__
// This is a work around for the combobox being simply dismissed when a
// choice is made in it under OS X. The bug is almost certainly due to a
@ -339,9 +335,9 @@ void GridCellFilamentsRenderer::Draw(wxGrid &grid, wxGridCellAttr &attr, wxDC &d
ObjectGridTable::ObjectGridRow *grid_row = table->get_grid_row(row - 1);
ConfigOptionInt & cur_option = dynamic_cast<ConfigOptionInt &>((*grid_row)[(ObjectGridTable::GridColType) col]);
wxBitmapBundle *bitmap = table->get_color_bitmap((cur_option.value >= 1) ? cur_option.value - 1 : cur_option.value);
int bitmap_width = bitmap->GetBitmapFor(dc.GetWindow()).GetWidth();
int bitmap_height = bitmap->GetBitmapFor(dc.GetWindow()).GetHeight();
wxBitmap *bitmap = table->get_color_bitmap((cur_option.value >= 1) ? cur_option.value - 1 : cur_option.value);
int bitmap_width = bitmap->GetWidth();
int bitmap_height = bitmap->GetHeight();
int offset_x = grid_cell_border_width;
int offset_y = (rect.height > bitmap_height) ? (rect.height - bitmap_height) / 2 : grid_cell_border_height;
@ -349,7 +345,7 @@ void GridCellFilamentsRenderer::Draw(wxGrid &grid, wxGridCellAttr &attr, wxDC &d
dc.SetBrush(wxBrush(attr.GetBackgroundColour()));
dc.DrawRectangle(rect);
if ( grid_row->model_volume_type != ModelVolumeType::NEGATIVE_VOLUME) {
dc.DrawBitmap(bitmap->GetBitmapFor(dc.GetWindow()), wxPoint(rect.x + offset_x, rect.y + offset_y));//TODO: determine if this way of getting bitmap works well
dc.DrawBitmap(*bitmap, wxPoint(rect.x + offset_x, rect.y + offset_y));
}
text_rect.x += bitmap_width + grid_cell_border_width * 2;
@ -435,9 +431,6 @@ void GridCellChoiceEditor::BeginEdit(int row, int col, wxGrid *grid)
Combo()->SetFocus();
// Orca: Show dropdown on editing start
Combo()->ToggleDropDown();
#ifdef __WXOSX_COCOA__
// This is a work around for the combobox being simply dismissed when a
// choice is made in it under OS X. The bug is almost certainly due to a
@ -525,16 +518,16 @@ void GridCellComboBoxRenderer::Draw(wxGrid &grid, wxGridCellAttr &attr, wxDC &dc
ObjectGridTable::ObjectGridRow *grid_row = table->get_grid_row(row - 1);
ConfigOptionInt & cur_option = dynamic_cast<ConfigOptionInt &>((*grid_row)[(ObjectGridTable::GridColType) col]);
wxBitmapBundle *bitmap = table->get_color_bitmap((cur_option.value >= 1) ? cur_option.value - 1 : cur_option.value);
int bitmap_width = bitmap->GetBitmapFor(dc.GetWindow()).GetWidth();
int bitmap_height = bitmap->GetBitmapFor(dc.GetWindow()).GetHeight();
wxBitmap *bitmap = table->get_color_bitmap((cur_option.value >= 1) ? cur_option.value - 1 : cur_option.value);
int bitmap_width = bitmap->GetWidth();
int bitmap_height = bitmap->GetHeight();
int offset_x = grid_cell_border_width;
int offset_y = (rect.height > bitmap_height) ? (rect.height - bitmap_height) / 2 : grid_cell_border_height;
dc.SetPen(*wxTRANSPARENT_PEN);
dc.SetBrush(wxBrush(attr.GetBackgroundColour()));
dc.DrawRectangle(rect);
dc.DrawBitmap(bitmap->GetBitmapFor(dc.GetWindow()), wxPoint(rect.x + offset_x, rect.y + offset_y));
dc.DrawBitmap(*bitmap, wxPoint(rect.x + offset_x, rect.y + offset_y));
text_rect.x += bitmap_width + grid_cell_border_width * 2;
text_rect.width -= (bitmap_width + grid_cell_border_width * 2);
}
@ -2648,12 +2641,12 @@ void ObjectGridTable::OnCellValueChanged(int row, int col)
}
}
wxBitmapBundle& ObjectGridTable::get_undo_bitmap(bool selected)
wxBitmap& ObjectGridTable::get_undo_bitmap(bool selected)
{
return m_panel->m_undo_bitmap;
}
wxBitmapBundle* ObjectGridTable::get_color_bitmap(int color_index)
wxBitmap* ObjectGridTable::get_color_bitmap(int color_index)
{
if (color_index < m_panel->m_color_bitmaps.size())
return m_panel->m_color_bitmaps[color_index];

View file

@ -82,10 +82,10 @@ public:
GridCellFilamentsEditor(size_t count = 0,
const wxString choices[] = NULL,
bool allowOthers = false,
std::vector<wxBitmapBundle*>* bitmaps = NULL);
std::vector<wxBitmap*>* bitmaps = NULL);
GridCellFilamentsEditor(const wxArrayString& choices,
bool allowOthers = false,
std::vector<wxBitmapBundle*>* bitmaps = NULL);
std::vector<wxBitmap*>* bitmaps = NULL);
virtual void Create(wxWindow* parent,
wxWindowID id,
@ -105,7 +105,7 @@ protected:
::ComboBox *Combo() const { return (::ComboBox *)m_control; }
void OnComboCloseUp(wxCommandEvent& evt);
std::vector<wxBitmapBundle*>* m_icons;
std::vector<wxBitmap*>* m_icons;
wxDECLARE_NO_COPY_CLASS(GridCellFilamentsEditor);
private:
@ -498,8 +498,8 @@ public:
void update_filament_to_config(ModelConfig* config, std::string& key, ConfigOption& new_value, ConfigOption& ori_value, bool is_object);
void update_volume_values_from_object(int row, int col);
void update_value_to_object(Model* model, ObjectGridRow* grid_row, int col);
wxBitmapBundle& get_undo_bitmap(bool selected = false);
wxBitmapBundle* get_color_bitmap(int color_index);
wxBitmap& get_undo_bitmap(bool selected = false);
wxBitmap* get_color_bitmap(int color_index);
bool OnCellLeftClick(int row, int col, ConfigOptionType &type);
void OnSelectCell(int row, int col);
void OnRangeSelected(int row, int col, int row_count, int col_count);
@ -610,10 +610,10 @@ private:
int init_filaments_and_colors();
wxFloatingPointValidator<float> m_float_validator;
wxBitmapBundle m_undo_bitmap;
std::vector<wxBitmapBundle*> m_color_bitmaps;
wxBitmapBundle m_bmp_reset;
wxBitmapBundle m_bmp_reset_disable;
wxBitmap m_undo_bitmap;
std::vector<wxBitmap*> m_color_bitmaps;
ScalableBitmap m_bmp_reset;
ScalableBitmap m_bmp_reset_disable;
private:
wxDECLARE_ABSTRACT_CLASS(ObjectGrid);
wxDECLARE_EVENT_TABLE();

View file

@ -173,7 +173,7 @@ bool ObjectTableSettings::update_settings_list(bool is_object, bool is_multiple_
btn->SetBitmapFocus(m_bmp_reset_focus.bmp());
btn->SetBitmapHover(m_bmp_reset_focus.get_bitmap());
btn->SetBitmapHover(m_bmp_reset_focus.bmp());
#ifdef __WINDOWS__
btn->SetBitmapDisabled(m_bmp_reset_disable.bmp());
@ -220,7 +220,7 @@ bool ObjectTableSettings::update_settings_list(bool is_object, bool is_multiple_
optgroup->sidetext_width = 5;
optgroup->set_config_category_and_type(GUI::from_u8(group_category), Preset::TYPE_PRINT);
std::weak_ptr weak_optgroup(optgroup);
std::weak_ptr<ConfigOptionsGroup> weak_optgroup(optgroup);
optgroup->m_on_change = [this, is_object, object, config, group_category](const t_config_option_key &opt_id, const boost::any &value) {
this->m_parent->Freeze();
this->update_config_values(is_object, object, config, group_category);
@ -236,7 +236,7 @@ bool ObjectTableSettings::update_settings_list(bool is_object, bool is_multiple_
return;
ctrl->SetBitmap_(m_bmp_reset);
ctrl->SetBitmapFocus(m_bmp_reset_focus.bmp());
ctrl->SetBitmapHover(m_bmp_reset_focus.get_bitmap());
ctrl->SetBitmapHover(m_bmp_reset_focus.bmp());
#ifdef __WINDOWS__
ctrl->SetBitmapDisabled(m_bmp_reset_disable.bmp());
#endif

View file

@ -668,7 +668,7 @@ void GLGizmoAdvancedCut::perform_cut(const Selection& selection)
if (its_num_open_edges(new_objects[i]->volumes[j]->mesh().its) > 0) {
if (!is_showed_dialog) {
is_showed_dialog = true;
MessageDialog dlg(nullptr, _L("non-mainifold edges be caused by cut tool, do you want to fix it now?"), "", wxYES | wxCANCEL);
MessageDialog dlg(nullptr, _L("non-manifold edges be caused by cut tool, do you want to fix it now?"), "", wxYES | wxCANCEL);
int ret = dlg.ShowModal();
if (ret == wxID_YES) {
user_fix_model = true;

View file

@ -3392,7 +3392,7 @@ void GLGizmoCut3D::perform_cut(const Selection& selection)
if (its_num_open_edges(new_objects[i]->volumes[j]->mesh().its) > 0) {
if (!is_showed_dialog) {
is_showed_dialog = true;
MessageDialog dlg(nullptr, _L("non-mainifold edges be caused by cut tool, do you want to fix it now?"), "", wxYES | wxCANCEL);
MessageDialog dlg(nullptr, _L("non-manifold edges be caused by cut tool, do you want to fix it now?"), "", wxYES | wxCANCEL);
int ret = dlg.ShowModal();
if (ret == wxID_YES) {
user_fix_model = true;

View file

@ -508,10 +508,10 @@ void ImageGrid::render(wxDC& dc)
if (!m_file_sys || m_file_sys->GetCount() == 0) {
dc.DrawRectangle({ 0, 0, size.x, size.y });
if (!m_status_msg.IsEmpty()) {
auto si = m_status_icon.GetSize();
auto si = m_status_icon.GetBmpSize();
auto st = dc.GetTextExtent(m_status_msg);
auto rect = wxRect{0, 0, max(st.x, si.x), si.y + 26 + st.y}.CenterIn(wxRect({0, 0}, size));
dc.DrawBitmap(m_status_icon.get_bitmap(), rect.x + (rect.width - si.x) / 2, rect.y);
dc.DrawBitmap(m_status_icon.bmp(), rect.x + (rect.width - si.x) / 2, rect.y);
dc.SetTextForeground(wxColor(0x909090));
dc.DrawText(m_status_msg, rect.x + (rect.width - st.x) / 2, rect.GetBottom() - st.y);
}
@ -602,7 +602,7 @@ void Slic3r::GUI::ImageGrid::renderContent1(wxDC &dc, wxPoint const &pt, int ind
bool show_download_state_always = true;
// Draw checked icon
if (m_selecting && !show_download_state_always)
dc.DrawBitmap(selected ? m_checked_icon.get_bitmap() : m_unchecked_icon.get_bitmap(), pt + wxPoint{10, m_content_rect.GetHeight() - m_checked_icon.GetHeight() - 10});
dc.DrawBitmap(selected ? m_checked_icon.bmp() : m_unchecked_icon.bmp(), pt + wxPoint{10, 10});
// can't handle alpha
// dc.GradientFillLinear({pt.x, pt.y, m_border_size.GetWidth(), 60}, wxColour(0x6F, 0x6F, 0x6F, 0x99), wxColour(0x6F, 0x6F, 0x6F, 0), wxBOTTOM);
else if (m_file_sys->GetGroupMode() == PrinterFileSystem::G_NONE) {
@ -653,7 +653,7 @@ void Slic3r::GUI::ImageGrid::renderContent1(wxDC &dc, wxPoint const &pt, int ind
dc.DrawText(date, pt + wxPoint{24, 16});
}
if (m_selecting && show_download_state_always)
dc.DrawBitmap(selected ? m_checked_icon.get_bitmap() : m_unchecked_icon.get_bitmap(), pt + wxPoint{10, m_content_rect.GetHeight() - m_checked_icon.GetHeight() - 10});
dc.DrawBitmap(selected ? m_checked_icon.bmp() : m_unchecked_icon.bmp(), pt + wxPoint{10, 10});
}
void Slic3r::GUI::ImageGrid::renderContent2(wxDC &dc, wxPoint const &pt, int index, bool hit)
@ -745,8 +745,8 @@ void Slic3r::GUI::ImageGrid::renderText2(wxDC &dc, wxString text, wxRect const &
void Slic3r::GUI::ImageGrid::renderIconText(wxDC & dc, ScalableBitmap const & icon, wxString text, wxRect const & rect)
{
dc.DrawBitmap(icon.get_bitmap(), rect.x, rect.y + (rect.height - icon.GetHeight()) / 2);
renderText2(dc, text, {rect.x + icon.GetWidth() + 4, rect.y, rect.width - icon.GetWidth() - 4, rect.height});
dc.DrawBitmap(icon.bmp(), rect.x, rect.y + (rect.height - icon.GetBmpHeight()) / 2);
renderText2(dc, text, {rect.x + icon.GetBmpWidth() + 4, rect.y, rect.width - icon.GetBmpWidth() - 4, rect.height});
}
}}

View file

@ -118,26 +118,20 @@ class PlaterWorker: public Worker {
}
};
void on_idle(wxIdleEvent &evt)
{
process_events();
evt.Skip();
}
EventGuard on_idle_evt;
EventGuard on_paint_evt;
public:
template<class... WorkerArgs>
PlaterWorker(wxWindow *plater, WorkerArgs &&...args)
: m_w{std::forward<WorkerArgs>(args)...}, m_plater{plater}
{
: m_w{std::forward<WorkerArgs>(args)...}
, m_plater{plater}
// Ensure that messages from the worker thread to the UI thread are
// processed continuously.
plater->Bind(wxEVT_IDLE, &PlaterWorker::on_idle, this);
}
~PlaterWorker()
, on_idle_evt(plater, wxEVT_IDLE, [this](wxIdleEvent&) { process_events(); })
, on_paint_evt(plater, wxEVT_PAINT, [this](wxPaintEvent&) { process_events(); })
{
m_plater->Unbind(wxEVT_IDLE, &PlaterWorker::on_idle, this);
}
// Always package the job argument into a PlaterJob

View file

@ -155,7 +155,7 @@ wxWindow *KBShortcutsDialog::create_button(int id, wxString text)
void KBShortcutsDialog::on_dpi_changed(const wxRect& suggested_rect)
{
m_logo_bmp.sys_color_changed();
m_logo_bmp.msw_rescale();
m_header_bitmap->SetBitmap(m_logo_bmp.bmp());
msw_buttons_rescale(this, em_unit(), { wxID_OK });
@ -258,7 +258,7 @@ void KBShortcutsDialog::fill_shortcuts()
{ "F", L("Gizmo Place face on bed") },
{ "L", L("Gizmo SLA support points") },
{ "P", L("Gizmo FDM paint-on seam") },
{ "Tab", L("Swtich between Prepare/Prewview") },
{ "Tab", L("Switch between Prepare/Preview") },
};
m_full_shortcuts.push_back({ { _L("Plater"), "" }, plater_shortcuts });
@ -300,7 +300,7 @@ void KBShortcutsDialog::fill_shortcuts()
{ L("Arrow Right"), L("Horizontal slider - Move active thumb Right")},
{ "L", L("On/Off one layer mode of the vertical slider")},
{ "C", L("On/Off g-code window")},
{ "Tab", L("Swtich between Prepare/Prewview") },
{ "Tab", L("Switch between Prepare/Preview") },
{L("Shift+Any arrow"), L("Move slider 5x faster")},
{L("Shift+Mouse wheel"), L("Move slider 5x faster")},
#ifdef __APPLE__

View file

@ -396,29 +396,20 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, BORDERLESS_FRAME_
sizer->SetSizeHints(this);
#ifdef WIN32
auto setMaxSize = [this]() {
wxDisplay display(this);
auto size = display.GetClientArea().GetSize();
HWND hWnd = GetHandle();
RECT borderThickness;
SetRectEmpty(&borderThickness);
AdjustWindowRectEx(&borderThickness, GetWindowLongPtr(hWnd, GWL_STYLE), FALSE, 0);
SetMaxSize(size + wxSize{-borderThickness.left + borderThickness.right, -borderThickness.top + borderThickness.bottom});
};
this->Bind(wxEVT_DPI_CHANGED, [setMaxSize](auto & e) {
setMaxSize();
e.Skip();
});
setMaxSize();
// SetMaximize already position window at left/top corner, even if Windows Task Bar is at left side.
// Not known why, but fix it here
// SetMaximize causes the window to overlap the taskbar, due to the fact this window has wxMAXIMIZE_BOX off
// https://forums.wxwidgets.org/viewtopic.php?t=50634
// Fix it here
this->Bind(wxEVT_MAXIMIZE, [this](auto &e) {
wxDisplay display(this);
auto pos = display.GetClientArea().GetPosition();
auto size = display.GetClientArea().GetSize();
auto pos = display.GetClientArea().GetPosition();
HWND hWnd = GetHandle();
RECT borderThickness;
SetRectEmpty(&borderThickness);
AdjustWindowRectEx(&borderThickness, GetWindowLongPtr(hWnd, GWL_STYLE), FALSE, 0);
const auto max_size = size + wxSize{-borderThickness.left + borderThickness.right, -borderThickness.top + borderThickness.bottom};
const auto current_size = GetSize();
SetSize({std::min(max_size.x, current_size.x), std::min(max_size.y, current_size.y)});
Move(pos + wxPoint{borderThickness.left, borderThickness.top});
e.Skip();
});
@ -1979,6 +1970,11 @@ void MainFrame::on_dpi_changed(const wxRect& suggested_rect)
m_monitor->msw_rescale();
m_calibration->msw_rescale();
// BBS
#if 0
for (size_t id = 0; id < m_menubar->GetMenuCount(); id++)
msw_rescale_menu(m_menubar->GetMenu(id));
#endif
// Workarounds for correct Window rendering after rescale
@ -2020,7 +2016,7 @@ void MainFrame::on_sys_color_changed()
#ifdef _MSW_DARK_MODE
// update common mode sizer
if (!wxGetApp().tabs_as_menu())
dynamic_cast<Notebook*>(m_tabpanel)->OnColorsChanged();
dynamic_cast<Notebook*>(m_tabpanel)->Rescale();
#endif
#endif
@ -3088,7 +3084,7 @@ void MainFrame::load_config_file()
// return;
wxFileDialog dlg(this, _L("Select profile to load:"),
!m_last_config.IsEmpty() ? get_dir_name(m_last_config) : wxGetApp().app_config->get_last_dir(),
"config.json", "Config files (*.json;*.zip;*.bbscfg;*.bbsflmt)|*.json;*.zip;*.bbscfg;*.bbsflmt", wxFD_OPEN | wxFD_MULTIPLE | wxFD_FILE_MUST_EXIST);
"config.json", "Config files (*.json;*.zip;*.orca_printer;*.orca_filament)|*.json;*.zip;*.orca_printer;*.orca_filament", wxFD_OPEN | wxFD_MULTIPLE | wxFD_FILE_MUST_EXIST);
wxArrayString files;
if (dlg.ShowModal() != wxID_OK)
return;
@ -3117,8 +3113,11 @@ void MainFrame::load_config_file()
}
wxGetApp().preset_bundle->update_compatible(PresetSelectCompatibleType::Always);
update_side_preset_ui();
MessageDialog dlg2(this, wxString::Format(_L_PLURAL("There is %d config imported. (Only non-system and compatible configs)",
"There are %d configs imported. (Only non-system and compatible configs)", cfiles.size()), cfiles.size()),
auto msg = wxString::Format(_L_PLURAL("There is %d config imported. (Only non-system and compatible configs)",
"There are %d configs imported. (Only non-system and compatible configs)", cfiles.size()), cfiles.size());
if(cfiles.empty())
msg += _L("\nHint: Make sure you have added the corresponding printer before importing the configs.");
MessageDialog dlg2(this,msg ,
_L("Import result"), wxOK);
dlg2.ShowModal();
}

View file

@ -354,9 +354,9 @@ void MediaFilePanel::SwitchStorage(bool external)
void MediaFilePanel::Rescale()
{
m_bmp_loading.sys_color_changed();
m_bmp_failed.sys_color_changed();
m_bmp_empty.sys_color_changed();
m_bmp_loading.msw_rescale();
m_bmp_failed.msw_rescale();
m_bmp_empty.msw_rescale();
auto top_sizer = GetSizer()->GetItem((size_t) 0)->GetSizer();
top_sizer->SetMinSize({-1, 75 * em_unit(this) / 10});

View file

@ -37,10 +37,10 @@ MediaPlayCtrl::MediaPlayCtrl(wxWindow *parent, wxMediaCtrl2 *media_ctrl, const w
m_button_play->Bind(wxEVT_COMMAND_BUTTON_CLICKED, [this](auto &e) { TogglePlay(); });
m_button_play->Bind(wxEVT_RIGHT_UP, [this](auto & e) { m_media_ctrl->Play(); });
m_label_status->Bind(wxEVT_LEFT_UP, [this](auto &e) {
auto url = wxString::Format(L"https://wiki.bambulab.com/%s/software/bambu-studio/faq/live-view", L"en");
wxLaunchDefaultBrowser(url);
});
// m_label_status->Bind(wxEVT_LEFT_UP, [this](auto &e) {
// auto url = wxString::Format(L"https://wiki.bambulab.com/%s/software/bambu-studio/faq/live-view", L"en");
// wxLaunchDefaultBrowser(url);
// });
Bind(wxEVT_RIGHT_UP, [this](auto & e) {
wxClipboard & c = *wxTheClipboard;

View file

@ -36,7 +36,7 @@ namespace GUI {
wxBoxSizer* m_sizer_web_control = new wxBoxSizer(wxHORIZONTAL);
auto m_control_back = new ScalableButton(m_web_control_panel, wxID_ANY, "mall_control_back", wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER);
auto m_control_back = new ScalableButton(m_web_control_panel, wxID_ANY, "mall_control_back", wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER, true);
m_control_back->SetBackgroundColour(*wxWHITE);
m_control_back->SetSize(wxSize(FromDIP(25), FromDIP(30)));
m_control_back->SetMinSize(wxSize(FromDIP(25), FromDIP(30)));
@ -47,7 +47,7 @@ namespace GUI {
m_control_back->Bind(wxEVT_LEAVE_WINDOW, [this](auto& e) {SetCursor(wxCursor(wxCURSOR_ARROW));});
auto m_control_forward = new ScalableButton(m_web_control_panel, wxID_ANY, "mall_control_forward", wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER);
auto m_control_forward = new ScalableButton(m_web_control_panel, wxID_ANY, "mall_control_forward", wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER, true);
m_control_forward->SetBackgroundColour(*wxWHITE);
m_control_forward->SetSize(wxSize(FromDIP(25), FromDIP(30)));
m_control_forward->SetMinSize(wxSize(FromDIP(25), FromDIP(30)));
@ -57,7 +57,7 @@ namespace GUI {
m_control_forward->Bind(wxEVT_ENTER_WINDOW, [this](auto& e) {SetCursor(wxCursor(wxCURSOR_HAND)); });
m_control_forward->Bind(wxEVT_LEAVE_WINDOW, [this](auto& e) {SetCursor(wxCursor(wxCURSOR_ARROW)); });
auto m_control_refresh = new ScalableButton(m_web_control_panel, wxID_ANY, "mall_control_refresh", wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER);
auto m_control_refresh = new ScalableButton(m_web_control_panel, wxID_ANY, "mall_control_refresh", wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER, true);
m_control_refresh->SetBackgroundColour(*wxWHITE);
m_control_refresh->SetSize(wxSize(FromDIP(25), FromDIP(30)));
m_control_refresh->SetMinSize(wxSize(FromDIP(25), FromDIP(30)));

View file

@ -227,10 +227,10 @@ void MsgDialog::apply_style(long style)
if (style & wxNO) add_button(wxID_NO, false,_L("No"));
if (style & wxCANCEL) add_button(wxID_CANCEL, false, _L("Cancel"));
logo->SetBitmap( *get_bmp_bundle(style & wxAPPLY ? "completed" :
logo->SetBitmap( create_scaled_bitmap(style & wxAPPLY ? "completed" :
style & wxICON_WARNING ? "obj_warning" :
style & wxICON_INFORMATION ? "info" :
style & wxICON_QUESTION ? "question" : "OrcaSlicer", 64));
style & wxICON_QUESTION ? "question" : "OrcaSlicer", this, 64, style & wxICON_ERROR));
}
void MsgDialog::finalize()
@ -339,7 +339,7 @@ ErrorDialog::ErrorDialog(wxWindow *parent, const wxString &msg, bool monospaced_
add_msg_content(this, content_sizer, msg, monospaced_font);
// Use a small bitmap with monospaced font, as the error text will not be wrapped.
logo->SetBitmap(*get_bmp_bundle("OrcaSlicer_192px_grayscale.png", monospaced_font ? 48 : /*1*/84));
logo->SetBitmap(create_scaled_bitmap("OrcaSlicer_192px_grayscale.png", this, monospaced_font ? 48 : /*1*/84));
SetMaxSize(wxSize(-1, CONTENT_MAX_HEIGHT*wxGetApp().em_unit()));

View file

@ -122,8 +122,6 @@ void ButtonsListCtrl::Rescale()
{
//m_mode_sizer->msw_rescale();
int em = em_unit(this);
// Orca: following is removed by PS in wx 3.16 refactor.
// doesn't seem to be doing anything rn so leaving it alone
for (Button* btn : m_pageButtons) {
//BBS
btn->SetMinSize({(btn->GetLabel().empty() ? 40 : 132) * em / 10, 36 * em / 10});
@ -139,14 +137,6 @@ void ButtonsListCtrl::Rescale()
m_sizer->Layout();
}
void ButtonsListCtrl::OnColorsChanged()
{
for (Button* btn : m_pageButtons)
btn->Rescale();
m_sizer->Layout();
}
void ButtonsListCtrl::SetSelection(int sel)
{
if (m_selection == sel)

View file

@ -23,7 +23,6 @@ public:
void SetSelection(int sel);
void UpdateMode();
void Rescale();
void OnColorsChanged();
bool InsertPage(size_t n, const wxString &text, bool bSelect = false, const std::string &bmp_name = "", const std::string &inactive_bmp_name = "");
void RemovePage(size_t n);
bool SetPageImage(size_t n, const std::string& bmp_name) const;
@ -262,11 +261,6 @@ public:
GetBtnsListCtrl()->Rescale();
}
void OnColorsChanged()
{
GetBtnsListCtrl()->OnColorsChanged();
}
void OnNavigationKey(wxNavigationKeyEvent& event)
{
if (event.IsWindowChange()) {

View file

@ -28,12 +28,12 @@ static bool is_point_in_rect(const wxPoint& pt, const wxRect& rect)
rect.GetTop() <= pt.y && pt.y <= rect.GetBottom();
}
static wxSize get_bitmap_size(const wxBitmapBundle* bmp, wxWindow* parent)
static wxSize get_bitmap_size(const wxBitmap& bmp)
{
#ifndef __WIN32__
return bmp->GetBitmapFor(parent).GetSize();
#ifdef __APPLE__
return bmp.GetScaledSize();
#else
return bmp->GetDefaultSize();
return bmp.GetSize();
#endif
}
@ -58,8 +58,8 @@ OG_CustomCtrl::OG_CustomCtrl( wxWindow* parent,
m_v_gap2 = lround(0.8 * m_em_unit);
m_h_gap = lround(0.2 * m_em_unit);
//m_bmp_mode_sz = get_bitmap_size(get_bmp_bundle("mode_simple", wxOSX ? 10 : 12), this);
m_bmp_blinking_sz = get_bitmap_size(get_bmp_bundle("blank_16"), this);
//m_bmp_mode_sz = get_bitmap_size(create_scaled_bitmap("mode_simple", this, wxOSX ? 10 : 12));
m_bmp_blinking_sz = get_bitmap_size(create_scaled_bitmap("blank_16", this));
init_ctrl_lines();// from og.lines()
@ -597,8 +597,8 @@ void OG_CustomCtrl::msw_rescale()
m_v_gap2 = lround(0.8 * m_em_unit);
m_h_gap = lround(0.2 * m_em_unit);
//m_bmp_mode_sz = get_bitmap_size(get_bmp_bundle("mode_simple", wxOSX ? 10 : 12), this);
m_bmp_blinking_sz = get_bitmap_size(get_bmp_bundle("blank_16"), this);
//m_bmp_mode_sz = create_scaled_bitmap("mode_simple", this, wxOSX ? 10 : 12).GetSize();
m_bmp_blinking_sz = create_scaled_bitmap("blank_16", this).GetSize();
m_max_win_width = 0;
@ -691,7 +691,7 @@ void OG_CustomCtrl::CtrlLine::msw_rescale()
{
// if we have a single option with no label, no sidetext
if (draw_just_act_buttons)
height = get_bitmap_size(get_bmp_bundle("empty"), ctrl).GetHeight();
height = get_bitmap_size(create_scaled_bitmap("empty")).GetHeight();
if (ctrl->opt_group->label_width != 0 && !og_line.label.IsEmpty()) {
wxSize label_sz = ctrl->GetTextExtent(og_line.label);
@ -773,8 +773,8 @@ void OG_CustomCtrl::CtrlLine::render(wxDC& dc, wxCoord h_pos, wxCoord v_pos)
if (field && field->undo_bitmap()) {
// if (field)
// BBS: new layout
const wxPoint pos = draw_act_bmps(dc, wxPoint(h_pos, v_pos), field->undo_to_sys_bitmap()->get_bitmap(),
field->undo_bitmap()->get_bitmap(), field->blink());
const wxPoint pos = draw_act_bmps(dc, wxPoint(h_pos, v_pos), field->undo_to_sys_bitmap()->bmp(),
field->undo_bitmap()->bmp(), field->blink());
if (field->has_edit_ui())
draw_edit_bmp(dc, pos, field->edit_bitmap());
}
@ -831,7 +831,7 @@ void OG_CustomCtrl::CtrlLine::render(wxDC& dc, wxCoord h_pos, wxCoord v_pos)
auto draw_buttons = [&h_pos, &dc, &v_pos, this](Field* field, size_t bmp_rect_id = 0) {
if (field && field->undo_to_sys_bitmap()) {
h_pos = draw_act_bmps(dc, wxPoint(h_pos, v_pos), field->undo_to_sys_bitmap()->get_bitmap(), field->undo_bitmap()->get_bitmap(), field->blink(), bmp_rect_id).x;
h_pos = draw_act_bmps(dc, wxPoint(h_pos, v_pos), field->undo_to_sys_bitmap()->bmp(), field->undo_bitmap()->bmp(), field->blink(), bmp_rect_id).x;
}
#ifndef DISABLE_BLINKING
else if (field && !field->undo_to_sys_bitmap() && field->blink())
@ -962,19 +962,19 @@ wxCoord OG_CustomCtrl::CtrlLine::draw_text(wxDC &dc, wxPoint pos, const wxString
wxPoint OG_CustomCtrl::CtrlLine::draw_blinking_bmp(wxDC& dc, wxPoint pos, bool is_blinking)
{
wxBitmapBundle* bmp_blinking = get_bmp_bundle(is_blinking ? "blank_16" : "empty");
wxBitmap bmp_blinking = create_scaled_bitmap(is_blinking ? "blank_16" : "empty", ctrl);
wxCoord h_pos = pos.x;
wxCoord v_pos = pos.y + lround((height - get_bitmap_size(bmp_blinking, ctrl).GetHeight()) / 2);
wxCoord v_pos = pos.y + lround((height - get_bitmap_size(bmp_blinking).GetHeight()) / 2);
dc.DrawBitmap(bmp_blinking->GetBitmapFor(ctrl), h_pos, v_pos);
dc.DrawBitmap(bmp_blinking, h_pos, v_pos);
int bmp_dim = get_bitmap_size(bmp_blinking, ctrl).GetWidth();
int bmp_dim = get_bitmap_size(bmp_blinking).GetWidth();
h_pos += bmp_dim + ctrl->m_h_gap;
return wxPoint(h_pos, v_pos);
}
wxPoint OG_CustomCtrl::CtrlLine::draw_act_bmps(wxDC& dc, wxPoint pos, const wxBitmapBundle& bmp_undo_to_sys, const wxBitmapBundle& bmp_undo, bool is_blinking, size_t rect_id)
wxPoint OG_CustomCtrl::CtrlLine::draw_act_bmps(wxDC& dc, wxPoint pos, const wxBitmap& bmp_undo_to_sys, const wxBitmap& bmp_undo, bool is_blinking, size_t rect_id)
{
#ifndef DISABLE_BLINKING
pos = draw_blinking_bmp(dc, pos, is_blinking);
@ -982,11 +982,11 @@ wxPoint OG_CustomCtrl::CtrlLine::draw_act_bmps(wxDC& dc, wxPoint pos, const wxBi
if (ctrl->opt_group->split_multi_line) { // BBS
const std::vector<Option> &option_set = og_line.get_options();
if (option_set.size() > 1)
pos.y += lround(((height - ctrl->m_v_gap + ctrl->m_v_gap2) / option_set.size() - get_bitmap_size(&bmp_undo, ctrl).GetHeight()) / 2);
pos.y += lround(((height - ctrl->m_v_gap + ctrl->m_v_gap2) / option_set.size() - get_bitmap_size(bmp_undo).GetHeight()) / 2);
else
pos.y += lround((height - get_bitmap_size(&bmp_undo, ctrl).GetHeight()) / 2);
pos.y += lround((height - get_bitmap_size(bmp_undo).GetHeight()) / 2);
} else {
pos.y += lround((height - get_bitmap_size(&bmp_undo, ctrl).GetHeight()) / 2);
pos.y += lround((height - get_bitmap_size(bmp_undo).GetHeight()) / 2);
}
#endif
wxCoord h_pos = pos.x;
@ -994,16 +994,16 @@ wxPoint OG_CustomCtrl::CtrlLine::draw_act_bmps(wxDC& dc, wxPoint pos, const wxBi
#ifndef DISABLE_UNDO_SYS
//BBS: GUI refactor
dc.DrawBitmap(bmp_undo_to_sys.GetBitmapFor(ctrl), h_pos, v_pos);
dc.DrawBitmap(bmp_undo_to_sys, h_pos, v_pos);
int bmp_dim = get_bitmap_size(&bmp_undo_to_sys, ctrl).GetWidth();
int bmp_dim = get_bitmap_size(bmp_undo_to_sys).GetWidth();
rects_undo_to_sys_icon[rect_id] = wxRect(h_pos, v_pos, bmp_dim, bmp_dim);
h_pos += bmp_dim + ctrl->m_h_gap;
#endif
dc.DrawBitmap(og_line.undo_to_sys ? bmp_undo_to_sys.GetBitmapFor(ctrl) : bmp_undo.GetBitmapFor(ctrl), h_pos, v_pos);
dc.DrawBitmap(og_line.undo_to_sys ? bmp_undo_to_sys : bmp_undo, h_pos, v_pos);
int bmp_dim2 = get_bitmap_size(&bmp_undo, ctrl).GetWidth();
int bmp_dim2 = get_bitmap_size(bmp_undo).GetWidth();
(og_line.undo_to_sys ? rects_undo_to_sys_icon[rect_id] : rects_undo_icon[rect_id]) = wxRect(h_pos, v_pos, bmp_dim2, bmp_dim2);
h_pos += bmp_dim2 + ctrl->m_h_gap;

View file

@ -64,7 +64,7 @@ class OG_CustomCtrl :public wxPanel
void render(wxDC& dc, wxCoord h_pos, wxCoord v_pos);
wxCoord draw_text (wxDC& dc, wxPoint pos, const wxString& text, const wxColour* color, int width, bool is_url = false, bool is_main = false);
wxPoint draw_blinking_bmp(wxDC& dc, wxPoint pos, bool is_blinking);
wxPoint draw_act_bmps(wxDC& dc, wxPoint pos, const wxBitmapBundle& bmp_undo_to_sys, const wxBitmapBundle& bmp_undo, bool is_blinking, size_t rect_id = 0);
wxPoint draw_act_bmps(wxDC& dc, wxPoint pos, const wxBitmap& bmp_undo_to_sys, const wxBitmap& bmp_undo, bool is_blinking, size_t rect_id = 0);
wxCoord draw_edit_bmp(wxDC& dc, wxPoint pos, const wxBitmapBundle* bmp_edit);
bool launch_browser() const;
bool is_separator() const { return og_line.is_separator(); }

View file

@ -4,6 +4,7 @@
///|/ PrusaSlicer is released under the terms of the AGPLv3 or higher
///|/
#include "ObjectDataViewModel.hpp"
#include "slic3r/GUI/wxExtensions.hpp"
#include "wxExtensions.hpp"
#include "BitmapCache.hpp"
#include "GUI_App.hpp"
@ -26,13 +27,6 @@ wxDEFINE_EVENT(wxCUSTOMEVT_LAST_VOLUME_IS_DELETED, wxCommandEvent);
BitmapCache* m_bitmap_cache = nullptr;
wxBitmapBundle* find_bndl(const std::string& bmp_name)
{
if (!m_bitmap_cache)
m_bitmap_cache = new BitmapCache;
return m_bitmap_cache->find_bndl(bmp_name);
}
// *****************************************************************************
// ----------------------------------------------------------------------------
@ -138,7 +132,7 @@ ObjectDataViewModelNode::ObjectDataViewModelNode(ObjectDataViewModelNode* parent
else if (type == itLayerRoot)
{
//BBS do not support layer range edit
m_bmp = *get_bmp_bundle(LayerRootIcon);
m_bmp = create_scaled_bitmap(LayerRootIcon);
m_name = _(L("Layers"));
}
else if (type == itInfo)
@ -169,7 +163,7 @@ ObjectDataViewModelNode::ObjectDataViewModelNode(ObjectDataViewModelNode* parent
}
const std::string label_range = (boost::format(" %.2f-%.2f ") % layer_range.first % layer_range.second).str();
m_name = _(L("Range")) + label_range + "(" + _(L("mm")) + ")";
m_bmp = *get_bmp_bundle(LayerIcon);
m_bmp = create_scaled_bitmap(LayerIcon);
set_icons();
init_container();
@ -187,15 +181,7 @@ bool ObjectDataViewModelNode::valid()
void ObjectDataViewModelNode::sys_color_changed()
{
m_printable_icon = m_printable == piUndef ? m_empty_bmp : *get_bmp_bundle(m_printable == piPrintable ? "check_on" : "check_off_focused");
if (!m_action_icon_name.empty())
m_action_icon = *get_bmp_bundle(m_action_icon_name);
if (!m_opt_categories.empty())
update_settings_digest_bitmaps();
set_extruder_icon();
m_printable_icon = m_printable == piUndef ? m_empty_bmp : create_scaled_bitmap(m_printable == piPrintable ? "check_on" : "check_off_focused");
}
void ObjectDataViewModelNode::set_icons()
@ -224,7 +210,7 @@ void ObjectDataViewModelNode::set_printable_icon(PrintIndicator printable)
return;
m_printable = printable;
m_printable_icon = m_printable == piUndef ? m_empty_bmp :
*get_bmp_bundle(m_printable == piPrintable ? "check_on" : "check_off_focused");
create_scaled_bitmap(m_printable == piPrintable ? "check_on" : "check_off_focused");
}
void ObjectDataViewModelNode::set_action_icon(bool enable)
@ -236,7 +222,7 @@ void ObjectDataViewModelNode::set_action_icon(bool enable)
m_action_icon_name = m_type & itPlate ? undo :
m_type & itObject ? undo :
m_type & (itVolume | itLayer) ? undo : /*m_type & itInstance*/ "set_separate_obj";
m_action_icon = *get_bmp_bundle(m_action_icon_name); // FIXME: pass window ptr
m_action_icon = create_scaled_bitmap(m_action_icon_name); // FIXME: pass window ptr
}
// BBS
@ -246,9 +232,9 @@ void ObjectDataViewModelNode::set_color_icon(bool enable)
return;
m_color_enable = enable;
if ((m_type & itObject) && enable)
m_color_icon = *get_bmp_bundle("mmu_segmentation");
m_color_icon = create_scaled_bitmap("mmu_segmentation");
else
m_color_icon = *get_bmp_bundle("dot");
m_color_icon = create_scaled_bitmap("dot");
}
void ObjectDataViewModelNode::set_support_icon(bool enable)
@ -257,9 +243,9 @@ void ObjectDataViewModelNode::set_support_icon(bool enable)
return;
m_support_enable = enable;
if ((m_type & itObject) && enable)
m_support_icon = *get_bmp_bundle("toolbar_support");
m_support_icon = create_scaled_bitmap("toolbar_support");
else
m_support_icon = *get_bmp_bundle("dot");
m_support_icon = create_scaled_bitmap("dot");
}
void ObjectDataViewModelNode::set_sinking_icon(bool enable)
@ -268,9 +254,9 @@ void ObjectDataViewModelNode::set_sinking_icon(bool enable)
return;
m_sink_enable = enable;
if ((m_type & itObject) && enable)
m_sinking_icon = *get_bmp_bundle("objlist_sinking");
m_sinking_icon = create_scaled_bitmap("objlist_sinking");
else
m_sinking_icon = *get_bmp_bundle("dot");
m_sinking_icon = create_scaled_bitmap("dot");
}
void ObjectDataViewModelNode::set_warning_icon(const std::string& warning_icon_name)
@ -285,14 +271,14 @@ void ObjectDataViewModelNode::update_settings_digest_bitmaps()
m_bmp = m_empty_bmp;
std::string scaled_bitmap_name = m_name.ToUTF8().data();
scaled_bitmap_name += (wxGetApp().dark_mode() ? "-dm" : "");
scaled_bitmap_name += "-em" + std::to_string(wxGetApp().em_unit()) + (wxGetApp().dark_mode() ? "-dm" : "");
wxBitmapBundle *bmp = find_bndl(scaled_bitmap_name);
wxBitmap *bmp = m_bitmap_cache->find(scaled_bitmap_name);
if (bmp == nullptr) {
std::vector<wxBitmapBundle*> bmps;
std::vector<wxBitmap> bmps;
for (auto& category : m_opt_categories)
bmps.emplace_back(SettingsFactory::get_category_bitmap(category));
bmp = m_bitmap_cache->insert_bndl(scaled_bitmap_name, bmps);
bmps.emplace_back(SettingsFactory::get_category_bitmap(category, false));
bmp = m_bitmap_cache->insert(scaled_bitmap_name, bmps);
}
m_bmp = *bmp;
@ -316,12 +302,26 @@ bool ObjectDataViewModelNode::update_settings_digest(const std::vector<std::stri
return true;
}
void ObjectDataViewModelNode::msw_rescale()
{
if (!m_action_icon_name.empty())
m_action_icon = create_scaled_bitmap(m_action_icon_name);
if (m_printable != piUndef)
m_printable_icon = create_scaled_bitmap(m_printable == piPrintable ? "obj_printable" : "obj_unprintable");
if (!m_opt_categories.empty())
update_settings_digest_bitmaps();
set_extruder_icon();
}
bool ObjectDataViewModelNode::SetValue(const wxVariant& variant, unsigned col)
{
switch (col)
{
case colPrint:
// m_printable_icon << variant;
m_printable_icon << variant;
return true;
case colName: {
DataViewBitmapText data;
@ -346,7 +346,7 @@ bool ObjectDataViewModelNode::SetValue(const wxVariant& variant, unsigned col)
m_color_icon << variant;
break;
case colEditing:
// m_action_icon << variant;
m_action_icon << variant;
return true;
default:
printf("MyObjectTreeModel::SetValue: wrong column");
@ -413,7 +413,7 @@ void ObjectDataViewModelNode::UpdateExtruderAndColorIcon(wxString extruder /*= "
if (extruder_idx > 0) --extruder_idx;
// Create the bitmap with color bars.
std::vector<wxBitmapBundle*> bmps = get_extruder_color_icons();// use wide icons
std::vector<wxBitmap*> bmps = get_extruder_color_icons(false);// use wide icons
if (bmps.empty()) {
m_extruder_bmp = wxNullBitmap;
return;
@ -450,12 +450,12 @@ ObjectDataViewModel::ObjectDataViewModel()
m_volume_bmps = MenuFactory::get_volume_bitmaps();
m_text_volume_bmps = MenuFactory::get_text_volume_bitmaps();
m_svg_volume_bmps = MenuFactory::get_svg_volume_bitmaps();
m_warning_bmp = *get_bmp_bundle(WarningIcon);
m_warning_manifold_bmp = *get_bmp_bundle(WarningManifoldIcon);
m_lock_bmp = *get_bmp_bundle(LockIcon);
m_warning_bmp = create_scaled_bitmap(WarningIcon);
m_warning_manifold_bmp = create_scaled_bitmap(WarningManifoldIcon);
m_lock_bmp = create_scaled_bitmap(LockIcon);
for (auto item : INFO_ITEMS)
m_info_bmps[item.first] = get_bmp_bundle(item.second.bmp_name);
m_info_bmps[item.first] = create_scaled_bitmap(item.second.bmp_name);
m_plate_outside = nullptr;
@ -538,9 +538,9 @@ void ObjectDataViewModel::UpdateBitmapForNode(ObjectDataViewModelNode *node)
if (!node->has_warning_icon() && !node->has_lock()) {
node->SetBitmap(is_volume_node ? (
node->is_text_volume() ? *m_text_volume_bmps.at(vol_type) :
node->is_svg_volume() ? *m_svg_volume_bmps.at(vol_type) :
*m_volume_bmps.at(vol_type)) : m_empty_bmp);
node->is_text_volume() ? m_text_volume_bmps.at(vol_type) :
node->is_svg_volume() ? m_svg_volume_bmps.at(vol_type) :
m_volume_bmps.at(vol_type)) : m_empty_bmp);
return;
}
@ -553,19 +553,19 @@ void ObjectDataViewModel::UpdateBitmapForNode(ObjectDataViewModelNode *node)
scaled_bitmap_name += std::to_string(vol_type);
scaled_bitmap_name += (wxGetApp().dark_mode() ? "-dm" : "-lm");
wxBitmapBundle* bmp = find_bndl(scaled_bitmap_name);
if (!bmp) {
std::vector<wxBitmapBundle*> bmps;
wxBitmap* bmp = m_bitmap_cache->find(scaled_bitmap_name);
if (bmp == nullptr) {
std::vector<wxBitmap> bmps;
if (node->has_warning_icon())
bmps.emplace_back(node->warning_icon_name() == WarningIcon ? &m_warning_bmp : &m_warning_manifold_bmp);
bmps.emplace_back(node->warning_icon_name() == WarningIcon ? m_warning_bmp : m_warning_manifold_bmp);
if (node->has_lock())
bmps.emplace_back(&m_lock_bmp);
bmps.emplace_back(m_lock_bmp);
if (is_volume_node)
bmps.emplace_back(
node->is_text_volume() ? m_text_volume_bmps[vol_type] :
node->is_svg_volume() ? m_svg_volume_bmps[vol_type] :
m_volume_bmps[vol_type]);
bmp = m_bitmap_cache->insert_bndl(scaled_bitmap_name, bmps);
bmp = m_bitmap_cache->insert(scaled_bitmap_name, bmps);
}
node->SetBitmap(*bmp);
@ -705,7 +705,7 @@ wxDataViewItem ObjectDataViewModel::AddInfoChild(const wxDataViewItem &parent_it
}
root->Insert(node, idx+1);
node->SetBitmap(*m_info_bmps.at(info_type));
node->SetBitmap(m_info_bmps.at(info_type));
// notify control
const wxDataViewItem child((void*)node);
ItemAdded(parent_item, child);
@ -1693,7 +1693,7 @@ wxString ObjectDataViewModel::GetName(const wxDataViewItem &item) const
return node->m_name;
}
wxBitmapBundle& ObjectDataViewModel::GetBitmap(const wxDataViewItem &item) const
wxBitmap& ObjectDataViewModel::GetBitmap(const wxDataViewItem &item) const
{
ObjectDataViewModelNode *node = static_cast<ObjectDataViewModelNode*>(item.GetID());
return node->m_bmp;
@ -1735,13 +1735,13 @@ void ObjectDataViewModel::GetValue(wxVariant &variant, const wxDataViewItem &ite
switch (col)
{
case colPrint:
variant << node->m_printable_icon.GetBitmapFor(m_ctrl);
variant << node->m_printable_icon;
break;
case colName:
variant << DataViewBitmapText(node->m_name, node->m_bmp.GetBitmapFor(m_ctrl));
variant << DataViewBitmapText(node->m_name, node->m_bmp);
break;
case colFilament:
variant << DataViewBitmapText(node->m_extruder, node->m_extruder_bmp.GetBitmapFor(m_ctrl));
variant << DataViewBitmapText(node->m_extruder, node->m_extruder_bmp);
break;
// BBS
case colSupportPaint:
@ -1754,7 +1754,7 @@ void ObjectDataViewModel::GetValue(wxVariant &variant, const wxDataViewItem &ite
variant << node->m_color_icon;
break;
case colEditing:
variant << node->m_action_icon.GetBitmapFor(m_ctrl);
variant << node->m_action_icon;
break;
default:
;
@ -2207,7 +2207,7 @@ void ObjectDataViewModel::SetVolumeType(const wxDataViewItem &item, const Slic3r
ObjectDataViewModelNode *node = static_cast<ObjectDataViewModelNode*>(item.GetID());
node->SetVolumeType(volume_type);
node->SetBitmap(*m_volume_bmps[int(volume_type)]);
node->SetBitmap(m_volume_bmps[int(volume_type)]);
if (volume_type != Slic3r::ModelVolumeType::MODEL_PART && volume_type != Slic3r::ModelVolumeType::PARAMETER_MODIFIER)
node->SetExtruder(""); // hide extruder
else if (node->GetExtruder().IsEmpty())
@ -2320,17 +2320,17 @@ void ObjectDataViewModel::SetSinkState(const bool painted, wxDataViewItem obj_it
ItemChanged(obj_item);
}
void ObjectDataViewModel::UpdateBitmaps()
void ObjectDataViewModel::Rescale()
{
m_volume_bmps = MenuFactory::get_volume_bitmaps();
m_text_volume_bmps = MenuFactory::get_text_volume_bitmaps();
m_svg_volume_bmps = MenuFactory::get_svg_volume_bitmaps();
m_warning_bmp = *get_bmp_bundle(WarningIcon);
m_warning_manifold_bmp = *get_bmp_bundle(WarningManifoldIcon);
m_lock_bmp = *get_bmp_bundle(LockIcon);
m_warning_bmp = create_scaled_bitmap(WarningIcon);
m_warning_manifold_bmp = create_scaled_bitmap(WarningManifoldIcon);
m_lock_bmp = create_scaled_bitmap(LockIcon);
for (auto item : INFO_ITEMS)
m_info_bmps[item.first] = get_bmp_bundle(item.second.bmp_name);
m_info_bmps[item.first] = create_scaled_bitmap(item.second.bmp_name);
wxDataViewItemArray all_items;
GetAllChildren(wxDataViewItem(0), all_items);
@ -2341,7 +2341,7 @@ void ObjectDataViewModel::UpdateBitmaps()
continue;
ObjectDataViewModelNode *node = static_cast<ObjectDataViewModelNode*>(item.GetID());
node->sys_color_changed();
node->msw_rescale();
switch (node->m_type)
{
@ -2350,13 +2350,13 @@ void ObjectDataViewModel::UpdateBitmaps()
UpdateBitmapForNode(node);
break;
case itLayerRoot:
node->m_bmp = *get_bmp_bundle(LayerRootIcon);
node->m_bmp = create_scaled_bitmap(LayerRootIcon);
break;
case itLayer:
node->m_bmp = *get_bmp_bundle(LayerIcon);
node->m_bmp = create_scaled_bitmap(LayerIcon);
break;
case itInfo:
node->m_bmp = *m_info_bmps.at(node->m_info_item_type);
node->m_bmp = m_info_bmps.at(node->m_info_item_type);
break;
default: break;
}

View file

@ -75,27 +75,27 @@ class ObjectDataViewModelNode
{
ObjectDataViewModelNode* m_parent;
MyObjectTreeModelNodePtrArray m_children;
wxBitmapBundle m_empty_bmp;
wxBitmap m_empty_bmp;
size_t m_volumes_cnt = 0;
std::vector< std::string > m_opt_categories;
t_layer_height_range m_layer_range = { 0.0f, 0.0f };
wxString m_name;
wxBitmapBundle& m_bmp = m_empty_bmp;
wxBitmap& m_bmp = m_empty_bmp;
ItemType m_type;
int m_idx = -1;
int m_plate_idx = -1;
bool m_container = false;
// BBS
wxString m_extruder = wxEmptyString;
wxBitmapBundle m_extruder_bmp;
wxBitmapBundle m_action_icon;
wxBitmap m_extruder_bmp;
wxBitmap m_action_icon;
// BBS
wxBitmapBundle m_support_icon;
wxBitmapBundle m_color_icon;
wxBitmapBundle m_sinking_icon;
wxBitmap m_support_icon;
wxBitmap m_color_icon;
wxBitmap m_sinking_icon;
PrintIndicator m_printable {piUndef};
wxBitmapBundle m_printable_icon;
wxBitmap m_printable_icon;
std::string m_warning_icon_name{ "" };
bool m_has_lock{false}; // for cut object icon
@ -229,11 +229,11 @@ public:
void SetName(const wxString &);
bool SetValue(const wxVariant &variant, unsigned int col);
void SetVolumeType(ModelVolumeType type) { m_volume_type = type; }
void SetBitmap(const wxBitmapBundle &icon) { m_bmp = icon; }
void SetBitmap(const wxBitmap &icon) { m_bmp = icon; }
void SetExtruder(const wxString &extruder) { m_extruder = extruder; }
void SetWarningIconName(const std::string& warning_icon_name) { m_warning_icon_name = warning_icon_name; }
void SetLock(bool has_lock) { m_has_lock = has_lock; }
const wxBitmapBundle& GetBitmap() const { return m_bmp; }
const wxBitmap& GetBitmap() const { return m_bmp; }
const wxString& GetName() const { return m_name; }
ItemType GetType() const { return m_type; }
InfoItemType GetInfoItemType() const { return m_info_item_type; }
@ -302,6 +302,7 @@ public:
bool is_text_volume() const { return m_is_text_volume; }
bool is_svg_volume() const { return m_is_svg_volume; }
void sys_color_changed();
void msw_rescale();
#ifndef NDEBUG
bool valid();
@ -327,14 +328,14 @@ class ObjectDataViewModel :public wxDataViewModel
{
std::vector<ObjectDataViewModelNode*> m_plates;
std::vector<ObjectDataViewModelNode*> m_objects;
std::vector<wxBitmapBundle*> m_volume_bmps;
std::vector<wxBitmapBundle*> m_text_volume_bmps;
std::vector<wxBitmapBundle*> m_svg_volume_bmps;
std::map<InfoItemType, wxBitmapBundle*> m_info_bmps;
wxBitmapBundle m_empty_bmp;
wxBitmapBundle m_warning_bmp;
wxBitmapBundle m_warning_manifold_bmp;
wxBitmapBundle m_lock_bmp;
std::vector<wxBitmap> m_volume_bmps;
std::vector<wxBitmap> m_text_volume_bmps;
std::vector<wxBitmap> m_svg_volume_bmps;
std::map<InfoItemType, wxBitmap> m_info_bmps;
wxBitmap m_empty_bmp;
wxBitmap m_warning_bmp;
wxBitmap m_warning_manifold_bmp;
wxBitmap m_lock_bmp;
ObjectDataViewModelNode* m_plate_outside;
@ -399,7 +400,7 @@ public:
// helper method for wxLog
wxString GetName(const wxDataViewItem &item) const;
wxBitmapBundle& GetBitmap(const wxDataViewItem &item) const;
wxBitmap& GetBitmap(const wxDataViewItem &item) const;
wxString GetExtruder(const wxDataViewItem &item) const;
int GetExtruderNumber(const wxDataViewItem &item) const;
@ -479,7 +480,7 @@ public:
void SetAssociatedControl(wxDataViewCtrl* ctrl) { m_ctrl = ctrl; }
// Rescale bitmaps for existing Items
void UpdateBitmaps();
void Rescale();
void AddWarningIcon(const wxDataViewItem& item, const std::string& warning_name);
void DeleteWarningIcon(const wxDataViewItem& item, const bool unmark_object = false);

View file

@ -845,6 +845,7 @@ void ConfigOptionsGroup::msw_rescale()
// check if window is ScalableButton
ScalableButton* sc_btn = dynamic_cast<ScalableButton*>(win);
if (sc_btn) {
sc_btn->msw_rescale();
sc_btn->SetSize(sc_btn->GetBestSize());
return;
}
@ -892,7 +893,7 @@ void ConfigOptionsGroup::sys_color_changed()
wxWindow* win = item->GetWindow();
// check if window is ScalableButton
if (ScalableButton* sc_btn = dynamic_cast<ScalableButton*>(win)) {
sc_btn->sys_color_changed();
sc_btn->msw_rescale();
return;
}
wxGetApp().UpdateDarkUI(win, dynamic_cast<wxButton*>(win) != nullptr);

View file

@ -233,11 +233,11 @@ ParamsPanel::ParamsPanel( wxWindow* parent, wxWindowID id, const wxPoint& pos, c
//m_search_btn->SetToolTip(format_wxstr(_L("Search in settings [%1%]"), "Ctrl+F"));
//m_search_btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent &) { wxGetApp().plater()->search(false); });
m_compare_btn = new ScalableButton(m_top_panel, wxID_ANY, "compare", wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER);
m_compare_btn = new ScalableButton(m_top_panel, wxID_ANY, "compare", wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER, true);
m_compare_btn->SetToolTip(_L("Compare presets"));
m_compare_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent e) { wxGetApp().mainframe->diff_dialog.show(); }));
m_setting_btn = new ScalableButton(m_top_panel, wxID_ANY, "table", wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER);
m_setting_btn = new ScalableButton(m_top_panel, wxID_ANY, "table", wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER, true);
m_setting_btn->SetToolTip(_L("View all object's settings"));
m_setting_btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent &) { wxGetApp().plater()->PopupObjectTable(-1, -1, {0, 0}); });
@ -646,11 +646,11 @@ void ParamsPanel::update_mode()
void ParamsPanel::msw_rescale()
{
if (m_process_icon) m_process_icon->sys_color_changed();
if (m_setting_btn) m_setting_btn->sys_color_changed();
if (m_search_btn) m_search_btn->sys_color_changed();
if (m_compare_btn) m_compare_btn->sys_color_changed();
if (m_tips_arrow) m_tips_arrow->sys_color_changed();
if (m_process_icon) m_process_icon->msw_rescale();
if (m_setting_btn) m_setting_btn->msw_rescale();
if (m_search_btn) m_search_btn->msw_rescale();
if (m_compare_btn) m_compare_btn->msw_rescale();
if (m_tips_arrow) m_tips_arrow->msw_rescale();
m_left_sizer->SetMinSize(wxSize(40 * em_unit(this), -1));
if (m_mode_sizer)
m_mode_sizer->SetMinSize(-1, 3 * em_unit(this));

View file

@ -4604,6 +4604,7 @@ void PartPlateList::update_logo_texture_filename(const std::string &texture_file
return !texture.empty() && (boost::algorithm::iends_with(texture, ".png") || boost::algorithm::iends_with(texture, ".svg")) && boost::filesystem::exists(texture, ec);
};
if (!texture_filename.empty() && !check_texture(texture_filename)) {
m_logo_texture_filename = "";
BOOST_LOG_TRIVIAL(error) << "Unable to load bed texture: " << texture_filename;
} else
m_logo_texture_filename = texture_filename;

View file

@ -515,6 +515,11 @@ void PhysicalPrinterDialog::on_dpi_changed(const wxRect& suggested_rect)
{
const int& em = em_unit();
m_printhost_browse_btn->msw_rescale();
m_printhost_test_btn->msw_rescale();
if (m_printhost_cafile_browse_btn)
m_printhost_cafile_browse_btn->msw_rescale();
m_optgroup->msw_rescale();
msw_buttons_rescale(this, em, { wxID_OK, wxID_CANCEL });
@ -526,15 +531,6 @@ void PhysicalPrinterDialog::on_dpi_changed(const wxRect& suggested_rect)
Refresh();
}
void PhysicalPrinterDialog::on_sys_color_changed()
{
m_printhost_browse_btn->sys_color_changed();
m_printhost_test_btn->sys_color_changed();
if (m_printhost_cafile_browse_btn)
m_printhost_cafile_browse_btn->sys_color_changed();
}
void PhysicalPrinterDialog::OnOK(wxEvent& event)
{
wxGetApp().get_tab(Preset::TYPE_PRINTER)->save_preset("", false, false, true, m_preset_name );

View file

@ -64,7 +64,7 @@ public:
protected:
void on_dpi_changed(const wxRect& suggested_rect) override;
void on_sys_color_changed() override;
void on_sys_color_changed() override {};
};

View file

@ -494,7 +494,7 @@ void Sidebar::priv::hide_rich_tip(wxButton* btn)
static struct DynamicFilamentList : DynamicList
{
std::vector<std::pair<wxString, wxBitmapBundle *>> items;
std::vector<std::pair<wxString, wxBitmap *>> items;
void apply_on(Choice *c) override
{
@ -533,8 +533,7 @@ static struct DynamicFilamentList : DynamicList
std::string type;
wxGetApp().preset_bundle->filaments.find_preset(presets[i])->get_filament_type(type);
str << type;
wxBitmapBundle* bmp = icons[i];
items.push_back({str, bmp});
items.push_back({str, icons[i]});
}
DynamicList::update();
}
@ -702,9 +701,6 @@ Sidebar::Sidebar(Plater *parent)
bed_type_title->SetFont(font);
SetCursor(wxCURSOR_ARROW);
});
bed_type_title->Bind(wxEVT_LEFT_UP, [bed_type_title, this](wxMouseEvent &e) {
wxLaunchDefaultBrowser("https://wiki.bambulab.com/en/x1/manual/compatibility-and-parameter-settings-of-filaments");
});
AppConfig *app_config = wxGetApp().app_config;
std::string str_bed_type = app_config->get("curr_bed_type");
@ -818,7 +814,9 @@ Sidebar::Sidebar(Plater *parent)
if (dlg.ShowModal() == wxID_OK) {
std::vector<float> matrix = dlg.get_matrix();
std::vector<float> extruders = dlg.get_extruders();
(project_config.option<ConfigOptionFloats>("flush_volumes_matrix"))->values = std::vector<double>(matrix.begin(), matrix.end());
(project_config.option<ConfigOptionFloats>("flush_volumes_vector"))->values = std::vector<double>(extruders.begin(), extruders.end());
(project_config.option<ConfigOptionFloat>("flush_multiplier"))->set(new ConfigOptionFloat(dlg.get_flush_multiplier()));
wxGetApp().preset_bundle->export_selections(*wxGetApp().app_config);
@ -879,7 +877,7 @@ Sidebar::Sidebar(Plater *parent)
bSizer39->Add(FromDIP(20), 0, 0, 0, 0);
ams_btn = new ScalableButton(p->m_panel_filament_title, wxID_ANY, "ams_fila_sync", wxEmptyString, wxDefaultSize, wxDefaultPosition,
wxBU_EXACTFIT | wxNO_BORDER, 18);
wxBU_EXACTFIT | wxNO_BORDER, false, 18);
ams_btn->SetToolTip(_L("Synchronize filament list from AMS"));
ams_btn->Bind(wxEVT_BUTTON, [this, scrolled_sizer](wxCommandEvent &e) {
sync_ams_list();
@ -1341,20 +1339,20 @@ void Sidebar::msw_rescale()
p->m_panel_printer_title->GetSizer()->SetMinSize(-1, 3 * wxGetApp().em_unit());
p->m_panel_filament_title->GetSizer()
->SetMinSize(-1, 3 * wxGetApp().em_unit());
p->m_printer_icon->sys_color_changed();
p->m_printer_setting->sys_color_changed();
p->m_filament_icon->sys_color_changed();
p->m_bpButton_add_filament->sys_color_changed();
p->m_bpButton_del_filament->sys_color_changed();
p->m_bpButton_ams_filament->sys_color_changed();
p->m_bpButton_set_filament->sys_color_changed();
p->m_printer_icon->msw_rescale();
p->m_printer_setting->msw_rescale();
p->m_filament_icon->msw_rescale();
p->m_bpButton_add_filament->msw_rescale();
p->m_bpButton_del_filament->msw_rescale();
p->m_bpButton_ams_filament->msw_rescale();
p->m_bpButton_set_filament->msw_rescale();
p->m_flushing_volume_btn->Rescale();
//BBS
m_bed_type_list->Rescale();
m_bed_type_list->SetMinSize({-1, 3 * wxGetApp().em_unit()});
#if 0
if (p->mode_sizer)
p->mode_sizer->sys_color_changed();
p->mode_sizer->msw_rescale();
#endif
//for (PlaterPresetComboBox* combo : std::vector<PlaterPresetComboBox*> { p->combo_print,
@ -1373,14 +1371,15 @@ void Sidebar::msw_rescale()
// BBS TODO: add msw_rescale for newly added windows
// BBS
//p->object_manipulation->msw_rescale();
p->object_settings->msw_rescale();
// BBS
#if 0
p->object_info->msw_rescale();
p->btn_send_gcode->sys_color_changed();
p->btn_send_gcode->msw_rescale();
// p->btn_eject_device->msw_rescale();
p->btn_export_gcode_removable->sys_color_changed();
p->btn_export_gcode_removable->msw_rescale();
#ifdef _WIN32
const int scaled_height = p->btn_export_gcode_removable->GetBitmapHeight();
#else
@ -1401,26 +1400,26 @@ void Sidebar::sys_color_changed()
#if 0
for (wxWindow* win : std::vector<wxWindow*>{ this, p->sliced_info->GetStaticBox(), p->object_info->GetStaticBox(), p->btn_reslice, p->btn_export_gcode })
wxGetApp().UpdateDarkUI(win);
p->object_info->sys_color_changed();
p->object_info->msw_rescale();
for (wxWindow* win : std::vector<wxWindow*>{ p->scrolled, p->presets_panel })
wxGetApp().UpdateAllStaticTextDarkUI(win);
#endif
//for (wxWindow* btn : std::vector<wxWindow*>{ p->btn_reslice, p->btn_export_gcode })
// wxGetApp().UpdateDarkUI(btn, true);
p->m_printer_icon->sys_color_changed();
p->m_printer_setting->sys_color_changed();
p->m_filament_icon->sys_color_changed();
p->m_bpButton_add_filament->sys_color_changed();
p->m_bpButton_del_filament->sys_color_changed();
p->m_bpButton_ams_filament->sys_color_changed();
p->m_bpButton_set_filament->sys_color_changed();
p->m_printer_icon->msw_rescale();
p->m_printer_setting->msw_rescale();
p->m_filament_icon->msw_rescale();
p->m_bpButton_add_filament->msw_rescale();
p->m_bpButton_del_filament->msw_rescale();
p->m_bpButton_ams_filament->msw_rescale();
p->m_bpButton_set_filament->msw_rescale();
p->m_flushing_volume_btn->Rescale();
// BBS
#if 0
if (p->mode_sizer)
p->mode_sizer->sys_color_changed();
p->mode_sizer->msw_rescale();
p->frequently_changed_parameters->sys_color_changed();
#endif
p->object_settings->sys_color_changed();
@ -1448,7 +1447,6 @@ void Sidebar::sys_color_changed()
//p->btn_export_gcode_removable->msw_rescale();
p->scrolled->Layout();
p->scrolled->Refresh();
p->searcher.dlg_sys_color_changed();
}
@ -8968,6 +8966,7 @@ void Plater::_calib_pa_tower(const Calib_Params& params) {
const double nozzle_diameter = printer_config->option<ConfigOptionFloats>("nozzle_diameter")->get_at(0);
filament_config->set_key_value("slow_down_layer_time", new ConfigOptionFloats{ 1.0f });
print_config->set_key_value("alternate_extra_wall", new ConfigOptionBool(false));
print_config->set_key_value("default_jerk", new ConfigOptionFloat(1.0f));
print_config->set_key_value("outer_wall_jerk", new ConfigOptionFloat(1.0f));
print_config->set_key_value("inner_wall_jerk", new ConfigOptionFloat(1.0f));
@ -9096,6 +9095,7 @@ void Plater::calib_flowrate(int pass) {
}
print_config->set_key_value("layer_height", new ConfigOptionFloat(layer_height));
print_config->set_key_value("alternate_extra_wall", new ConfigOptionBool(false));
print_config->set_key_value("initial_layer_print_height", new ConfigOptionFloat(first_layer_height));
print_config->set_key_value("reduce_crossing_wall", new ConfigOptionBool(true));
//filament_config->set_key_value("filament_max_volumetric_speed", new ConfigOptionFloats{ 9. });
@ -9123,6 +9123,7 @@ void Plater::calib_temp(const Calib_Params& params) {
model().objects[0]->config.set_key_value("brim_type", new ConfigOptionEnum<BrimType>(btOuterOnly));
model().objects[0]->config.set_key_value("brim_width", new ConfigOptionFloat(5.0));
model().objects[0]->config.set_key_value("brim_object_gap", new ConfigOptionFloat(0.0));
model().objects[0]->config.set_key_value("alternate_extra_wall", new ConfigOptionBool(false));
changed_objects({ 0 });
wxGetApp().get_tab(Preset::TYPE_PRINT)->update_dirty();
@ -9191,6 +9192,7 @@ void Plater::calib_max_vol_speed(const Calib_Params& params)
print_config->set_key_value("enable_overhang_speed", new ConfigOptionBool { false });
print_config->set_key_value("timelapse_type", new ConfigOptionEnum<TimelapseType>(tlTraditional));
print_config->set_key_value("wall_loops", new ConfigOptionInt(1));
print_config->set_key_value("alternate_extra_wall", new ConfigOptionBool(false));
print_config->set_key_value("top_shell_layers", new ConfigOptionInt(0));
print_config->set_key_value("bottom_shell_layers", new ConfigOptionInt(0));
print_config->set_key_value("sparse_infill_density", new ConfigOptionPercent(0));
@ -9256,6 +9258,7 @@ void Plater::calib_retraction(const Calib_Params& params)
obj->config.set_key_value("sparse_infill_density", new ConfigOptionPercent(0));
obj->config.set_key_value("initial_layer_print_height", new ConfigOptionFloat(layer_height));
obj->config.set_key_value("layer_height", new ConfigOptionFloat(layer_height));
obj->config.set_key_value("alternate_extra_wall", new ConfigOptionBool(false));
changed_objects({ 0 });
@ -9285,10 +9288,12 @@ void Plater::calib_VFA(const Calib_Params& params)
print_config->set_key_value("enable_overhang_speed", new ConfigOptionBool { false });
print_config->set_key_value("timelapse_type", new ConfigOptionEnum<TimelapseType>(tlTraditional));
print_config->set_key_value("wall_loops", new ConfigOptionInt(1));
print_config->set_key_value("alternate_extra_wall", new ConfigOptionBool(false));
print_config->set_key_value("top_shell_layers", new ConfigOptionInt(0));
print_config->set_key_value("bottom_shell_layers", new ConfigOptionInt(1));
print_config->set_key_value("sparse_infill_density", new ConfigOptionPercent(0));
print_config->set_key_value("overhang_reverse", new ConfigOptionBool(false));
print_config->set_key_value("detect_thin_wall", new ConfigOptionBool(false));
print_config->set_key_value("spiral_mode", new ConfigOptionBool(true));
model().objects[0]->config.set_key_value("brim_type", new ConfigOptionEnum<BrimType>(btOuterOnly));
model().objects[0]->config.set_key_value("brim_width", new ConfigOptionFloat(3.0));
@ -12452,6 +12457,8 @@ void Plater::msw_rescale()
p->sidebar->msw_rescale();
p->menus.msw_rescale();
Layout();
GetParent()->Layout();
}

View file

@ -159,19 +159,16 @@ wxBoxSizer *PreferencesDialog::create_item_language_combobox(
language_name = wxString::FromUTF8("\xED\x95\x9C\xEA\xB5\xAD\xEC\x96\xB4");
}
else if (vlist[i] == wxLocale::GetLanguageInfo(wxLANGUAGE_RUSSIAN)) {
language_name = wxString::FromUTF8("\xD0\xA0\xD1\x83\xD1\x81\xD1\x81\xD0\xBA\xD0\xB8\xD0\xB9");
}
else if (vlist[i] == wxLocale::GetLanguageInfo(wxLANGUAGE_CZECH)) {
language_name = wxString::FromUTF8("\xC4\x8D\x65\xC5\xA1\x74\x69\x6E\x61");
language_name = wxString::FromUTF8("\xd0\xa0\xd1\x83\xd1\x81\xd1\x81\xd0\xba\xd0\xb8\xd0\xb9");
}
else if (vlist[i] == wxLocale::GetLanguageInfo(wxLANGUAGE_UKRAINIAN)) {
language_name = wxString::FromUTF8("\xC4\x8D\x65\xC5\xA1\x74\x69\x6E\x61");
language_name = wxString::FromUTF8("Ukrainian");
}
else if (vlist[i] == wxLocale::GetLanguageInfo(wxLANGUAGE_TURKISH)) {
language_name = wxString::FromUTF8("\xD1\x83\xD0\xBA\xD1\x80\xD0\xB0\xD1\x97\xD1\x9D\xD1\x81\xD1\x8C\xD0\xBA\xD0\xB0");
language_name = wxString::FromUTF8("Turkish");
}
if (language == vlist[i]->CanonicalName) {
if (app_config->get(param) == vlist[i]->CanonicalName) {
m_current_language_selected = i;
}
combobox->Append(language_name);
@ -999,6 +996,7 @@ wxWindow* PreferencesDialog::create_general_page()
auto item_region= create_item_region_combobox(_L("Login Region"), page, _L("Login Region"), Regions);
auto item_stealth_mode = create_item_checkbox(_L("Stealth Mode"), page, _L("Stealth Mode"), 50, "stealth_mode");
auto item_check_stable_version_only = create_item_checkbox(_L("Check for stable updates only"), page, _L("Check for stable updates only"), 50, "check_stable_update_only");
std::vector<wxString> Units = {_L("Metric") + " (mm, g)", _L("Imperial") + " (in, oz)"};
auto item_currency = create_item_combobox(_L("Units"), page, _L("Units"), "use_inches", Units);
@ -1075,6 +1073,7 @@ wxWindow* PreferencesDialog::create_general_page()
sizer_page->Add(item_hints, 0, wxTOP, FromDIP(3));
sizer_page->Add(title_presets, 0, wxTOP | wxEXPAND, FromDIP(20));
sizer_page->Add(item_stealth_mode, 0, wxTOP, FromDIP(3));
sizer_page->Add(item_check_stable_version_only, 0, wxTOP, FromDIP(3));
sizer_page->Add(item_calc_mode, 0, wxTOP, FromDIP(3));
sizer_page->Add(item_user_sync, 0, wxTOP, FromDIP(3));
sizer_page->Add(item_system_sync, 0, wxTOP, FromDIP(3));

View file

@ -112,8 +112,8 @@ PresetComboBox::PresetComboBox(wxWindow* parent, Preset::Type preset_type, const
default: break;
}
m_bitmapCompatible = get_bmp_bundle("flag_green");
m_bitmapIncompatible = get_bmp_bundle("flag_red");
m_bitmapCompatible = ScalableBitmap(this, "flag_green");
m_bitmapIncompatible = ScalableBitmap(this, "flag_red");
// parameters for an icon's drawing
fill_width_height();
@ -295,12 +295,12 @@ void PresetComboBox::update(std::string select_preset_name)
const std::deque<Preset>& presets = m_collection->get_presets();
std::map<wxString, std::pair<wxBitmapBundle*, bool>> nonsys_presets;
std::map<wxString, wxBitmapBundle*> incomp_presets;
std::map<wxString, std::pair<wxBitmap*, bool>> nonsys_presets;
std::map<wxString, wxBitmap*> incomp_presets;
wxString selected = "";
if (!presets.front().is_visible)
set_label_marker(Append(separator(L("System presets")), NullBitmapBndl()));
set_label_marker(Append(separator(L("System presets")), wxNullBitmap));
for (size_t i = presets.front().is_visible ? 0 : m_collection->num_default_presets(); i < presets.size(); ++i)
{
@ -313,7 +313,7 @@ void PresetComboBox::update(std::string select_preset_name)
if (select_preset_name.empty() && is_enabled)
select_preset_name = preset.name;
wxBitmapBundle* bmp = get_bmp(preset);
wxBitmap* bmp = get_bmp(preset);
assert(bmp);
if (!is_enabled)
@ -325,17 +325,17 @@ void PresetComboBox::update(std::string select_preset_name)
}
else
{
nonsys_presets.emplace(get_preset_name(preset), std::pair<wxBitmapBundle*, bool>(bmp, is_enabled));
nonsys_presets.emplace(get_preset_name(preset), std::pair<wxBitmap*, bool>(bmp, is_enabled));
if (preset.name == select_preset_name || (select_preset_name.empty() && is_enabled))
selected = get_preset_name(preset);
}
if (i + 1 == m_collection->num_default_presets())
set_label_marker(Append(separator(L("System presets")), NullBitmapBndl()));
set_label_marker(Append(separator(L("System presets")), wxNullBitmap));
}
if (!nonsys_presets.empty())
{
set_label_marker(Append(separator(L("User presets")), NullBitmapBndl()));
for (std::map<wxString, std::pair<wxBitmapBundle*, bool>>::iterator it = nonsys_presets.begin(); it != nonsys_presets.end(); ++it) {
set_label_marker(Append(separator(L("User presets")), wxNullBitmap));
for (std::map<wxString, std::pair<wxBitmap*, bool>>::iterator it = nonsys_presets.begin(); it != nonsys_presets.end(); ++it) {
int item_id = Append(it->first, *it->second.first);
bool is_enabled = it->second.second;
if (!is_enabled)
@ -345,8 +345,8 @@ void PresetComboBox::update(std::string select_preset_name)
}
if (!incomp_presets.empty())
{
set_label_marker(Append(separator(L("Incompatible presets")), NullBitmapBndl()));
for (std::map<wxString, wxBitmapBundle*>::iterator it = incomp_presets.begin(); it != incomp_presets.end(); ++it) {
set_label_marker(Append(separator(L("Incompatible presets")), wxNullBitmap));
for (std::map<wxString, wxBitmap*>::iterator it = incomp_presets.begin(); it != incomp_presets.end(); ++it) {
set_label_marker(Append(it->first, *it->second), LABEL_ITEM_DISABLED);
}
}
@ -363,8 +363,7 @@ void PresetComboBox::show_all(bool show_all)
void PresetComboBox::update()
{
int n = this->GetSelection();
this->update(n < 0 ? "" : into_u8(this->GetString(n)));
this->update(into_u8(this->GetString(this->GetSelection())));
}
void PresetComboBox::update_from_bundle()
@ -400,7 +399,9 @@ void PresetComboBox::add_ams_filaments(std::string selected, bool alias_name)
const_cast<Preset&>(*iter).is_visible = true;
auto color = tray.opt_string("filament_colour", 0u);
auto name = tray.opt_string("tray_name", 0u);
int item_id = Append(get_preset_name(*iter), *get_extruder_color_icon(color, name, 24, 16), &m_first_ams_filament + entry.first);
wxBitmap bmp(*get_extruder_color_icon(color, name, 24, 16));
int item_id = Append(get_preset_name(*iter), bmp.ConvertToImage(), &m_first_ams_filament + entry.first);
//validate_selection(id->value == selected); // can not select
}
m_last_ams_filament = GetCount();
}
@ -418,24 +419,29 @@ void PresetComboBox::msw_rescale()
{
m_em_unit = em_unit(this);
Rescale();
m_bitmapIncompatible.msw_rescale();
m_bitmapCompatible.msw_rescale();
// parameters for an icon's drawing
fill_width_height();
// update the control to redraw the icons
update();
}
void PresetComboBox::sys_color_changed()
{
m_bitmapCompatible = get_bmp_bundle("flag_green");
m_bitmapIncompatible = get_bmp_bundle("flag_red");
wxGetApp().UpdateDarkUI(this);
// update the control to redraw the icons
update();
msw_rescale();
}
void PresetComboBox::fill_width_height()
{
// To avoid asserts, each added bitmap to wxBitmapCombobox should be the same size, so
// set a bitmap's height to m_bitmapCompatible->GetHeight() and norm_icon_width to m_bitmapCompatible->GetWidth()
icon_height = 16;
norm_icon_width = 16;
icon_height = m_bitmapCompatible.GetBmpHeight();
norm_icon_width = m_bitmapCompatible.GetBmpWidth();
/* It's supposed that standard size of an icon is 16px*16px for 100% scaled display.
* So set sizes for solid_colored icons used for filament preset
@ -446,11 +452,9 @@ void PresetComboBox::fill_width_height()
thin_icon_width = lroundf(8 * scale_f); // analogue to 8px;
wide_icon_width = norm_icon_width + thin_icon_width;
null_icon_width = 2 * norm_icon_width;
space_icon_width = 2;
thin_space_icon_width = 4;
wide_space_icon_width = 6;
space_icon_width = lroundf(2 * scale_f);
thin_space_icon_width = lroundf(4 * scale_f);
wide_space_icon_width = lroundf(6 * scale_f);
}
wxString PresetComboBox::separator(const std::string& label)
@ -458,15 +462,15 @@ wxString PresetComboBox::separator(const std::string& label)
return wxString::FromUTF8(separator_head()) + _(label) + wxString::FromUTF8(separator_tail());
}
wxBitmapBundle* PresetComboBox::get_bmp( std::string bitmap_key, bool wide_icons, const std::string& main_icon_name,
wxBitmap* PresetComboBox::get_bmp( std::string bitmap_key, bool wide_icons, const std::string& main_icon_name,
bool is_compatible/* = true*/, bool is_system/* = false*/, bool is_single_bar/* = false*/,
const std::string& filament_rgb/* = ""*/, const std::string& extruder_rgb/* = ""*/, const std::string& material_rgb/* = ""*/)
{
// BBS: no icon
#if 1
static wxBitmapBundle bmp;
static wxBitmap bmp;
return &bmp;
#else // if this is updated, refer to PrusaSlicer for updates
#else
// 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)
@ -479,52 +483,52 @@ wxBitmapBundle* PresetComboBox::get_bmp( std::string bitmap_key, bool wide_icon
bitmap_key += ",dark";
bitmap_key += material_rgb;
wxBitmapBundle* bmp_bndl = bitmap_cache().find_bndl(bitmap_key);
if (bmp_bndl == nullptr) {
wxBitmap* bmp = bitmap_cache().find(bitmap_key);
if (bmp == nullptr) {
// Create the bitmap with color bars.
std::vector<wxBitmapBundle*> bmps;
std::vector<wxBitmap> bmps;
if (wide_icons)
// Paint a red flag for incompatible presets.
bmps.emplace_back(is_compatible ? get_empty_bmp_bundle(norm_icon_width, icon_height) : m_bitmapIncompatible);
bmps.emplace_back(is_compatible ? bitmap_cache().mkclear(norm_icon_width, icon_height) : m_bitmapIncompatible.bmp());
if (m_type == Preset::TYPE_FILAMENT && !filament_rgb.empty())
{
// BBS
// Paint a lock at the system presets.
bmps.emplace_back(get_empty_bmp_bundle(space_icon_width, icon_height));
bmps.emplace_back(bitmap_cache().mkclear(space_icon_width, icon_height));
}
else
{
// BBS
#if 0
// Paint the color bars.
bmps.emplace_back(get_empty_bmp_bundle(thin_space_icon_width, icon_height));
bmps.emplace_back(bitmap_cache().mkclear(thin_space_icon_width, icon_height));
if (m_type == Preset::TYPE_SLA_MATERIAL)
bmps.emplace_back(bitmap_cache().from_svg(main_icon_name, 16, 16, dark_mode, material_rgb));
bmps.emplace_back(create_scaled_bitmap(main_icon_name, this, 16, false, material_rgb));
else
bmps.emplace_back(get_bmp_bundle(main_icon_name));
bmps.emplace_back(create_scaled_bitmap(main_icon_name));
#endif
// Paint a lock at the system presets.
bmps.emplace_back(get_empty_bmp_bundle(wide_space_icon_width, icon_height));
bmps.emplace_back(bitmap_cache().mkclear(wide_space_icon_width, icon_height));
}
bmps.emplace_back(is_system ? get_bmp_bundle("unlock_normal") : get_empty_bmp_bundle(norm_icon_width, icon_height));
bmp_bndl = bitmap_cache().insert_bndl(bitmap_key, bmps);
bmps.emplace_back(is_system ? create_scaled_bitmap("unlock_normal") : bitmap_cache().mkclear(norm_icon_width, icon_height));
bmp = bitmap_cache().insert(bitmap_key, bmps);
}
return bmp_bndl;
return bmp;
#endif
}
wxBitmapBundle* PresetComboBox::get_bmp(Preset const &preset)
wxBitmap *PresetComboBox::get_bmp(Preset const &preset)
{
static wxBitmapBundle sbmp;
static wxBitmap sbmp;
if (m_type == Preset::TYPE_FILAMENT) {
Preset const & preset2 = &m_collection->get_selected_preset() == &preset ? m_collection->get_edited_preset() : preset;
wxString color = preset2.config.opt_string("default_filament_colour", 0);
wxColour clr(color);
if (clr.IsOk()) {
std::string bitmap_key = "default_filament_colour_" + color.ToStdString();
wxBitmapBundle *bmp = bitmap_cache().find_bndl(bitmap_key);
wxBitmap *bmp = bitmap_cache().find(bitmap_key);
if (bmp == nullptr) {
wxImage img(16, 16);
if (clr.Red() > 224 && clr.Blue() > 224 && clr.Green() > 224) {
@ -533,8 +537,8 @@ wxBitmapBundle* PresetComboBox::get_bmp(Preset const &preset)
} else {
img.SetRGB(wxRect({0, 0}, img.GetSize()), clr.Red(), clr.Green(), clr.Blue());
}
bmp = new wxBitmapBundle(img);
bmp = bitmap_cache().insert_bndl(bitmap_key, *bmp);
bmp = new wxBitmap(img);
bmp = bitmap_cache().insert(bitmap_key, *bmp);
}
return bmp;
}
@ -542,14 +546,14 @@ wxBitmapBundle* PresetComboBox::get_bmp(Preset const &preset)
return &sbmp;
}
wxBitmapBundle *PresetComboBox::get_bmp(std::string bitmap_key,
wxBitmap *PresetComboBox::get_bmp(std::string bitmap_key,
const std::string &main_icon_name,
const std::string &next_icon_name,
bool is_enabled/* = true*/, bool is_compatible/* = true*/, bool is_system/* = false*/)
{
// BBS: no icon
#if 1
static wxBitmapBundle bmp;
static wxBitmap bmp;
return &bmp;
#else
bitmap_key += !is_enabled ? "_disabled" : "";
@ -559,27 +563,21 @@ wxBitmapBundle *PresetComboBox::get_bmp(std::string bitmap_key,
if (wxGetApp().dark_mode())
bitmap_key += ",dark";
wxBitmapBundle* bmp = bitmap_cache().find_bndl(bitmap_key);
wxBitmap* bmp = bitmap_cache().find(bitmap_key);
if (bmp == nullptr) {
// Create the bitmap with color bars.
std::vector<wxBitmapBundle*> bmps;
bmps.emplace_back(m_type == Preset::TYPE_PRINTER ? get_bmp_bundle(main_icon_name, this, 16, !is_enabled) :
is_compatible ? m_bitmapCompatible : m_bitmapIncompatible);
std::vector<wxBitmap> bmps;
bmps.emplace_back(m_type == Preset::TYPE_PRINTER ? create_scaled_bitmap(main_icon_name, this, 16, !is_enabled) :
is_compatible ? m_bitmapCompatible.bmp() : m_bitmapIncompatible.bmp());
// Paint a lock at the system presets.
bmps.emplace_back(is_system ? get_bmp_bundle(next_icon_name) : get_empty_bmp_bundle(norm_icon_width, icon_height));
bmp = bitmap_cache().insert_bndl(bitmap_key, bmps);
bmps.emplace_back(is_system ? create_scaled_bitmap(next_icon_name, this, 16, !is_enabled) : bitmap_cache().mkclear(norm_icon_width, icon_height));
bmp = bitmap_cache().insert(bitmap_key, bmps);
}
return bmp;
#endif
}
wxBitmapBundle PresetComboBox::NullBitmapBndl()
{
assert(null_icon_width > 0);
return *get_empty_bmp_bundle(null_icon_width, icon_height);
}
bool PresetComboBox::is_selected_physical_printer()
{
auto selected_item = this->GetSelection();
@ -946,12 +944,10 @@ void PlaterPresetComboBox::update()
// and draw a red flag in front of the selected preset.
bool wide_icons = selected_preset && !selected_preset->is_compatible;
null_icon_width = (wide_icons ? 3 : 2) * norm_icon_width + thin_space_icon_width + wide_space_icon_width;
std::map<wxString, wxBitmapBundle*> nonsys_presets;
std::map<wxString, wxBitmap*> nonsys_presets;
//BBS: add project embedded presets logic
std::map<wxString, wxBitmapBundle*> project_embedded_presets;
std::map<wxString, wxBitmapBundle*> system_presets;
std::map<wxString, wxBitmap*> project_embedded_presets;
std::map<wxString, wxBitmap*> system_presets;
//BBS: move system to the end
wxString selected_system_preset;
@ -961,7 +957,7 @@ void PlaterPresetComboBox::update()
//BBS: move system to the end
/*if (!presets.front().is_visible)
this->set_label_marker(this->Append(separator(L("System presets")), NullBitmapBndl()));*/
this->set_label_marker(this->Append(separator(L("System presets")), wxNullBitmap));*/
for (size_t i = presets.front().is_visible ? 0 : m_collection->num_default_presets(); i < presets.size(); ++i)
{
@ -989,7 +985,7 @@ void PlaterPresetComboBox::update()
#endif
}
wxBitmapBundle* bmp = get_bmp(preset);
wxBitmap* bmp = get_bmp(preset);
assert(bmp);
const std::string name = preset.alias.empty() ? preset.name : preset.alias;
@ -1034,16 +1030,16 @@ void PlaterPresetComboBox::update()
//BBS: add project embedded preset logic
if (!project_embedded_presets.empty())
{
set_label_marker(Append(separator(L("Project-inside presets")), NullBitmapBndl()));
for (std::map<wxString, wxBitmapBundle*>::iterator it = project_embedded_presets.begin(); it != project_embedded_presets.end(); ++it) {
set_label_marker(Append(separator(L("Project-inside presets")), wxNullBitmap));
for (std::map<wxString, wxBitmap*>::iterator it = project_embedded_presets.begin(); it != project_embedded_presets.end(); ++it) {
Append(it->first, *it->second);
validate_selection(it->first == selected_user_preset);
}
}
if (!nonsys_presets.empty())
{
set_label_marker(Append(separator(L("User presets")), NullBitmapBndl()));
for (std::map<wxString, wxBitmapBundle*>::iterator it = nonsys_presets.begin(); it != nonsys_presets.end(); ++it) {
set_label_marker(Append(separator(L("User presets")), wxNullBitmap));
for (std::map<wxString, wxBitmap*>::iterator it = nonsys_presets.begin(); it != nonsys_presets.end(); ++it) {
Append(it->first, *it->second);
validate_selection(it->first == selected_user_preset);
}
@ -1051,8 +1047,8 @@ void PlaterPresetComboBox::update()
//BBS: move system to the end
if (!system_presets.empty())
{
set_label_marker(Append(separator(L("System presets")), NullBitmapBndl()));
for (std::map<wxString, wxBitmapBundle*>::iterator it = system_presets.begin(); it != system_presets.end(); ++it) {
set_label_marker(Append(separator(L("System presets")), wxNullBitmap));
for (std::map<wxString, wxBitmap*>::iterator it = system_presets.begin(); it != system_presets.end(); ++it) {
Append(it->first, *it->second);
validate_selection(it->first == selected_system_preset);
}
@ -1063,7 +1059,7 @@ void PlaterPresetComboBox::update()
{
// add Physical printers, if any exists
if (!m_preset_bundle->physical_printers.empty()) {
set_label_marker(Append(separator(L("Physical printers")), NullBitmapBndl()));
set_label_marker(Append(separator(L("Physical printers")), wxNullBitmap));
const PhysicalPrinterCollection& ph_printers = m_preset_bundle->physical_printers;
for (PhysicalPrinterCollection::ConstIterator it = ph_printers.begin(); it != ph_printers.end(); ++it) {
@ -1072,7 +1068,7 @@ void PlaterPresetComboBox::update()
if (!preset || !preset->is_visible)
continue;
std::string main_icon_name, bitmap_key = main_icon_name = preset->printer_technology() == ptSLA ? "sla_printer" : m_main_bitmap_name;
auto bmp = get_bmp(main_icon_name, wide_icons, main_icon_name);
wxBitmap* bmp = get_bmp(main_icon_name, wide_icons, main_icon_name);
assert(bmp);
set_label_marker(Append(from_u8(it->get_full_name(preset_name) + suffix(preset)), *bmp), LABEL_ITEM_PHYSICAL_PRINTER);
@ -1083,7 +1079,7 @@ void PlaterPresetComboBox::update()
}*/
if (m_type == Preset::TYPE_PRINTER || m_type == Preset::TYPE_FILAMENT || m_type == Preset::TYPE_SLA_MATERIAL) {
wxBitmapBundle* bmp = get_bmp("edit_preset_list", wide_icons, "edit_uni");
wxBitmap* bmp = get_bmp("edit_preset_list", wide_icons, "edit_uni");
assert(bmp);
if (m_type == Preset::TYPE_FILAMENT)
@ -1125,23 +1121,12 @@ void PlaterPresetComboBox::msw_rescale()
if (clr_picker)
clr_picker->SetSize(20 * m_em_unit / 10, 20 * m_em_unit / 10);
#ifdef __WXMSW__
// Use this part of code just on Windows to avoid of some layout issues on Linux
// see https://github.com/prusa3d/PrusaSlicer/issues/5163 and https://github.com/prusa3d/PrusaSlicer/issues/5505
// Update control min size after rescale (changed Display DPI under MSW)
if (GetMinWidth() != 20 * m_em_unit)
SetMinSize(wxSize(20 * m_em_unit, GetSize().GetHeight()));
#endif //__WXMSW__
}
void PlaterPresetComboBox::sys_color_changed()
{
PresetComboBox::sys_color_changed();
// BBS
if (edit_btn != nullptr)
edit_btn->sys_color_changed();
edit_btn->msw_rescale();
}
// ---------------------------------
// *** TabPresetComboBox ***
// ---------------------------------
@ -1208,16 +1193,16 @@ void TabPresetComboBox::update()
const std::deque<Preset>& presets = m_collection->get_presets();
std::map<wxString, std::pair<wxBitmapBundle*, bool>> nonsys_presets;
std::map<wxString, std::pair<wxBitmap*, bool>> nonsys_presets;
//BBS: add project embedded presets logic
std::map<wxString, std::pair<wxBitmapBundle*, bool>> project_embedded_presets;
std::map<wxString, std::pair<wxBitmap*, bool>> project_embedded_presets;
//BBS: move system to the end
std::map<wxString, std::pair<wxBitmapBundle*, bool>> system_presets;
std::map<wxString, std::pair<wxBitmap*, bool>> system_presets;
wxString selected = "";
//BBS: move system to the end
/*if (!presets.front().is_visible)
set_label_marker(Append(separator(L("System presets")), NullBitmapBndl()));*/
set_label_marker(Append(separator(L("System presets")), wxNullBitmap));*/
size_t idx_selected = m_collection->get_selected_idx();
if (m_type == Preset::TYPE_PRINTER && m_preset_bundle->physical_printers.has_selection()) {
@ -1236,12 +1221,12 @@ void TabPresetComboBox::update()
// marker used for disable incompatible printer models for the selected physical printer
bool is_enabled = true;
wxBitmapBundle* bmp = get_bmp(preset);
wxBitmap* bmp = get_bmp(preset);
assert(bmp);
if (preset.is_default || preset.is_system) {
//BBS: move system to the end
system_presets.emplace(get_preset_name(preset), std::pair<wxBitmapBundle *, bool>(bmp, is_enabled));
system_presets.emplace(get_preset_name(preset), std::pair<wxBitmap *, bool>(bmp, is_enabled));
if (i == idx_selected)
selected = get_preset_name(preset);
//int item_id = Append(get_preset_name(preset), *bmp);
@ -1253,20 +1238,20 @@ void TabPresetComboBox::update()
else if (preset.is_project_embedded)
{
//std::pair<wxBitmap*, bool> pair(bmp, is_enabled);
project_embedded_presets.emplace(get_preset_name(preset), std::pair<wxBitmapBundle *, bool>(bmp, is_enabled));
project_embedded_presets.emplace(get_preset_name(preset), std::pair<wxBitmap *, bool>(bmp, is_enabled));
if (i == idx_selected)
selected = get_preset_name(preset);
}
else
{
std::pair<wxBitmapBundle*, bool> pair(bmp, is_enabled);
nonsys_presets.emplace(get_preset_name(preset), std::pair<wxBitmapBundle*, bool>(bmp, is_enabled));
std::pair<wxBitmap*, bool> pair(bmp, is_enabled);
nonsys_presets.emplace(get_preset_name(preset), std::pair<wxBitmap*, bool>(bmp, is_enabled));
if (i == idx_selected)
selected = get_preset_name(preset);
}
//BBS: move system to the end
//if (i + 1 == m_collection->num_default_presets())
// set_label_marker(Append(separator(L("System presets")), NullBitmapBndl()));
// set_label_marker(Append(separator(L("System presets")), wxNullBitmap));
}
if (m_type == Preset::TYPE_FILAMENT && m_preset_bundle->is_bbl_vendor())
@ -1276,7 +1261,7 @@ void TabPresetComboBox::update()
if (!project_embedded_presets.empty())
{
set_label_marker(Append(separator(L("Project-inside presets")), wxNullBitmap));
for (std::map<wxString, std::pair<wxBitmapBundle*, bool>>::iterator it = project_embedded_presets.begin(); it != project_embedded_presets.end(); ++it) {
for (std::map<wxString, std::pair<wxBitmap*, bool>>::iterator it = project_embedded_presets.begin(); it != project_embedded_presets.end(); ++it) {
int item_id = Append(it->first, *it->second.first);
bool is_enabled = it->second.second;
if (!is_enabled)
@ -1286,8 +1271,8 @@ void TabPresetComboBox::update()
}
if (!nonsys_presets.empty())
{
set_label_marker(Append(separator(L("User presets")), NullBitmapBndl()));
for (std::map<wxString, std::pair<wxBitmapBundle*, bool>>::iterator it = nonsys_presets.begin(); it != nonsys_presets.end(); ++it) {
set_label_marker(Append(separator(L("User presets")), wxNullBitmap));
for (std::map<wxString, std::pair<wxBitmap*, bool>>::iterator it = nonsys_presets.begin(); it != nonsys_presets.end(); ++it) {
int item_id = Append(it->first, *it->second.first);
bool is_enabled = it->second.second;
if (!is_enabled)
@ -1299,7 +1284,7 @@ void TabPresetComboBox::update()
if (!system_presets.empty())
{
set_label_marker(Append(separator(L("System presets")), wxNullBitmap));
for (std::map<wxString, std::pair<wxBitmapBundle*, bool>>::iterator it = system_presets.begin(); it != system_presets.end(); ++it) {
for (std::map<wxString, std::pair<wxBitmap*, bool>>::iterator it = system_presets.begin(); it != system_presets.end(); ++it) {
int item_id = Append(it->first, *it->second.first);
bool is_enabled = it->second.second;
if (!is_enabled)
@ -1313,7 +1298,7 @@ void TabPresetComboBox::update()
//BBS: remove unused pysical printer logic
/*// add Physical printers, if any exists
if (!m_preset_bundle->physical_printers.empty()) {
set_label_marker(Append(separator(L("Physical printers")), NullBitmapBndl()));
set_label_marker(Append(separator(L("Physical printers")), wxNullBitmap));
const PhysicalPrinterCollection& ph_printers = m_preset_bundle->physical_printers;
for (PhysicalPrinterCollection::ConstIterator it = ph_printers.begin(); it != ph_printers.end(); ++it) {
@ -1323,7 +1308,7 @@ void TabPresetComboBox::update()
continue;
std::string main_icon_name = preset->printer_technology() == ptSLA ? "sla_printer" : m_main_bitmap_name;
auto bmp = get_bmp(main_icon_name, main_icon_name, "", true, true, false);
wxBitmap* bmp = get_bmp(main_icon_name, main_icon_name, "", true, true, false);
assert(bmp);
set_label_marker(Append(from_u8(it->get_full_name(preset_name) + suffix(preset)), *bmp), LABEL_ITEM_PHYSICAL_PRINTER);
@ -1334,14 +1319,14 @@ void TabPresetComboBox::update()
// add "Add/Remove printers" item
//std::string icon_name = "edit_uni";
//auto bmp = get_bmp("edit_preset_list, tab,", icon_name, "");
//wxBitmap* bmp = get_bmp("edit_preset_list, tab,", icon_name, "");
//assert(bmp);
//set_label_marker(Append(separator(L("Add/Remove printers")), *bmp), LABEL_ITEM_WIZARD_PRINTERS);
}
// BBS Add/Remove filaments select
//wxBitmapBundle* bmp = get_bmp("edit_preset_list", false, "edit_uni");
//wxBitmap* bmp = get_bmp("edit_preset_list", false, "edit_uni");
//assert(bmp);
//if (m_type == Preset::TYPE_FILAMENT)
// set_label_marker(Append(separator(L("Add/Remove filaments")), *bmp), LABEL_ITEM_WIZARD_FILAMENTS);
@ -1501,7 +1486,7 @@ void GUI::CalibrateFilamentComboBox::update()
tooltip = get_tooltip(preset);
}
wxBitmapBundle* bmp = get_bmp(preset);
wxBitmap* bmp = get_bmp(preset);
assert(bmp);
if (preset.is_default || preset.is_system) {
@ -1544,7 +1529,7 @@ void GUI::CalibrateFilamentComboBox::msw_rescale()
}
// BBS
if (edit_btn != nullptr)
edit_btn->sys_color_changed();
edit_btn->msw_rescale();
}
void GUI::CalibrateFilamentComboBox::OnSelect(wxCommandEvent &evt)

View file

@ -1,7 +1,7 @@
#ifndef slic3r_PresetComboBoxes_hpp_
#define slic3r_PresetComboBoxes_hpp_
#include <wx/bmpbndl.h>
//#include <wx/bmpcbox.h>
#include <wx/gdicmn.h>
#include <wx/clrpicker.h>
@ -37,7 +37,7 @@ public:
PresetComboBox(wxWindow* parent, Preset::Type preset_type, const wxSize& size = wxDefaultSize, PresetBundle* preset_bundle = nullptr);
~PresetComboBox();
enum LabelItemType : size_t {
enum LabelItemType {
LABEL_ITEM_PHYSICAL_PRINTER = 0xffffff01,
LABEL_ITEM_DISABLED,
LABEL_ITEM_MARKER,
@ -99,9 +99,9 @@ protected:
static BitmapCache& bitmap_cache();
// Indicator, that the preset is compatible with the selected printer.
wxBitmapBundle* m_bitmapCompatible;
ScalableBitmap m_bitmapCompatible;
// Indicator, that the preset is NOT compatible with the selected printer.
wxBitmapBundle* m_bitmapIncompatible;
ScalableBitmap m_bitmapIncompatible;
int m_last_selected;
int m_em_unit;
@ -115,7 +115,6 @@ protected:
// parameters for an icon's drawing
int icon_height;
int norm_icon_width;
int null_icon_width;
int thin_icon_width;
int wide_icon_width;
int space_icon_width;
@ -140,16 +139,14 @@ protected:
#endif // __linux__
static wxString separator(const std::string& label);
wxBitmapBundle* get_bmp( std::string bitmap_key, bool wide_icons, const std::string& main_icon_name,
wxBitmap* get_bmp( std::string bitmap_key, bool wide_icons, const std::string& main_icon_name,
bool is_compatible = true, bool is_system = false, bool is_single_bar = false,
const std::string& filament_rgb = "", const std::string& extruder_rgb = "", const std::string& material_rgb = "");
wxBitmapBundle* get_bmp( std::string bitmap_key, const std::string& main_icon_name, const std::string& next_icon_name,
wxBitmap* get_bmp( std::string bitmap_key, const std::string& main_icon_name, const std::string& next_icon_name,
bool is_enabled = true, bool is_compatible = true, bool is_system = false);
wxBitmapBundle* get_bmp(Preset const &preset);
wxBitmapBundle NullBitmapBndl();
wxBitmap *get_bmp(Preset const &preset);
private:
void fill_width_height();
@ -182,7 +179,6 @@ public:
wxString get_preset_name(const Preset& preset) override;
void update() override;
void msw_rescale() override;
void sys_color_changed() override;
void OnSelect(wxCommandEvent& evt) override;
private:
@ -249,8 +245,8 @@ private:
bool m_filament_exist{false};
bool m_is_compatible{true};
const Preset* m_selected_preset = nullptr;
std::map<wxString, std::pair<std::string, wxBitmapBundle*>> m_nonsys_presets;
std::map<wxString, std::pair<std::string, wxBitmapBundle*>> m_system_presets;
std::map<wxString, std::pair<std::string, wxBitmap*>> m_nonsys_presets;
std::map<wxString, std::pair<std::string, wxBitmap*>> m_system_presets;
};
} // namespace GUI

View file

@ -94,16 +94,16 @@ void RecenterDialog::render(wxDC& dc) {
wxSize hint1_size = dc.GetTextExtent(hint1);
wxPoint pos_hint1 = pos_start;
pos_hint1.y += (m_home_bmp.GetWidth() - hint1_size.y) / 2;
pos_hint1.y += (m_home_bmp.GetBmpWidth() - hint1_size.y) / 2;
dc.DrawText(hint1, pos_hint1);
wxPoint pos_bmp = pos_start;
pos_bmp.x += hint1_size.x;
dc.DrawBitmap(m_home_bmp.get_bitmap(), pos_bmp);
dc.DrawBitmap(m_home_bmp.bmp(), pos_bmp);
wxSize hint2_size = dc.GetTextExtent(hint2);
wxPoint pos_hint2 = pos_hint1;
pos_hint2.x = pos_hint2.x + hint1_size.x + m_home_bmp.GetWidth();
pos_hint2.x = pos_hint2.x + hint1_size.x + m_home_bmp.GetBmpWidth();
if (hint2_size.x + pos_hint2.x + BORDER > DRAW_PANEL_SIZE.x) {
bool is_ch = false;

View file

@ -23,6 +23,7 @@
#include <algorithm>
#include "Plater.hpp"
#include "BitmapCache.hpp"
#include "slic3r/GUI/GUI_App.hpp"
namespace Slic3r { namespace GUI {
@ -293,7 +294,8 @@ UpdateVersionDialog::UpdateVersionDialog(wxWindow *parent)
m_vebview_release_note->Bind(wxEVT_WEBVIEW_NAVIGATING,[=](wxWebViewEvent& event){
static bool load_url_first = false;
if(load_url_first){
wxLaunchDefaultBrowser(url_line);
// Orca: not used in Orca Slicer
// wxLaunchDefaultBrowser(url_line);
event.Veto();
}else{
load_url_first = true;
@ -317,11 +319,6 @@ UpdateVersionDialog::UpdateVersionDialog(wxWindow *parent)
m_bitmap_open_in_browser = new wxStaticBitmap(this, wxID_ANY, create_scaled_bitmap("open_in_browser", this, 12), wxDefaultPosition, wxDefaultSize, 0 );
m_link_open_in_browser = new wxHyperlinkCtrl(this, wxID_ANY, "Open in browser", "");
m_link_open_in_browser->SetFont(Label::Body_12);
auto sizer_button = new wxBoxSizer(wxHORIZONTAL);
@ -357,6 +354,17 @@ UpdateVersionDialog::UpdateVersionDialog(wxWindow *parent)
EndModal(wxID_NO);
});
m_cb_stable_only = new CheckBox(this);
m_cb_stable_only->SetValue(wxGetApp().app_config->get_bool("check_stable_update_only"));
m_cb_stable_only->Bind(wxEVT_TOGGLEBUTTON, [this](wxCommandEvent& e) {
wxGetApp().app_config->set_bool("check_stable_update_only", m_cb_stable_only->GetValue());
e.Skip();
});
auto stable_only_label = new Label(this, _L("Check for stable updates only"));
stable_only_label->SetFont(Label::Body_13);
stable_only_label->SetForegroundColour(wxColour(38, 46, 48));
stable_only_label->SetFont(Label::Body_12);
m_button_cancel = new Button(this, _L("Cancel"));
m_button_cancel->SetBackgroundColor(btn_bg_white);
@ -372,10 +380,10 @@ UpdateVersionDialog::UpdateVersionDialog(wxWindow *parent)
m_sizer_main->Add(m_line_top, 0, wxEXPAND | wxBOTTOM, 0);
sizer_button->Add(m_bitmap_open_in_browser, 0, wxALIGN_CENTER | wxLEFT, FromDIP(7));
sizer_button->Add(m_link_open_in_browser, 0, wxALIGN_CENTER| wxLEFT, FromDIP(3));
//sizer_button->Add(m_remind_choice, 0, wxALL | wxEXPAND, FromDIP(5));
sizer_button->AddStretchSpacer();
sizer_button->Add(stable_only_label, 0, wxALIGN_CENTER | wxLEFT, FromDIP(7));
sizer_button->Add(m_cb_stable_only, 0, wxALIGN_CENTER | wxLEFT, FromDIP(5));
sizer_button->Add(m_button_download, 0, wxALL, FromDIP(5));
sizer_button->Add(m_button_skip_version, 0, wxALL, FromDIP(5));
sizer_button->Add(m_button_cancel, 0, wxALL, FromDIP(5));
@ -510,7 +518,6 @@ void UpdateVersionDialog::update_version_info(wxString release_note, wxString ve
m_text_up_info->Hide();
m_simplebook_release_note->SetSelection(1);
m_vebview_release_note->LoadURL(from_u8(url_line));
m_link_open_in_browser->SetURL(url_line);
}
else {
m_simplebook_release_note->SetMaxSize(wxSize(FromDIP(560), FromDIP(430)));

View file

@ -99,8 +99,8 @@ public:
wxBoxSizer * sizer_text_release_note{nullptr};
Label * m_staticText_release_note{nullptr};
wxStaticBitmap* m_bitmap_open_in_browser;
wxHyperlinkCtrl* m_link_open_in_browser;
Button* m_button_skip_version;
CheckBox* m_cb_stable_only;
Button* m_button_download;
Button* m_button_cancel;
std::string url_line;

View file

@ -57,7 +57,7 @@ SavePresetDialog::Item::Item(Preset::Type type, const std::string &suffix, wxBox
label_top->SetForegroundColour(wxColour(38,46,48));
// m_valid_bmp = new wxStaticBitmap(m_parent, wxID_ANY, *get_bmp_bundle("blank_16"));
// m_valid_bmp = new wxStaticBitmap(m_parent, wxID_ANY, create_scaled_bitmap("blank_16", m_parent));
//
// m_combo = new wxComboBox(m_parent, wxID_ANY, from_u8(preset_name), wxDefaultPosition, wxSize(35 * wxGetApp().em_unit(), -1));
// for (const std::string& value : values)
@ -268,7 +268,7 @@ void SavePresetDialog::Item::update()
void SavePresetDialog::Item::update_valid_bmp()
{
std::string bmp_name = m_valid_type == Warning ? "obj_warning" : m_valid_type == NoValid ? "cross" : "blank_16";
m_valid_bmp->SetBitmap(*get_bmp_bundle(bmp_name));
m_valid_bmp->SetBitmap(create_scaled_bitmap(bmp_name, m_parent));
}
void SavePresetDialog::Item::accept()

View file

@ -829,9 +829,12 @@ void SearchDialog::msw_rescale()
{
/* const int &em = GUI::wxGetApp().em_unit();
search_list_model->msw_rescale();
search_list->GetColumn(SearchListModel::colIcon )->SetWidth(3 * em);
search_list->GetColumn(SearchListModel::colMarkedText)->SetWidth(45 * em);
msw_buttons_rescale(this, em, { wxID_CANCEL });
const wxSize& size = wxSize(40 * em, 30 * em);
SetMinSize(size);
@ -849,7 +852,7 @@ void SearchDialog::msw_rescale()
//#endif
//
// // msw_rescale updates just icons, so use it
// search_list_model->sys_color_changed();
// search_list_model->msw_rescale();
//
// Refresh();
//}
@ -881,10 +884,9 @@ void SearchListModel::Prepend(const std::string &label)
RowPrepended();
}
void SearchListModel::sys_color_changed()
void SearchListModel::msw_rescale()
{
for (ScalableBitmap &bmp : m_icon)
bmp.sys_color_changed();
for (ScalableBitmap &bmp : m_icon) bmp.msw_rescale();
}
wxString SearchListModel::GetColumnType(unsigned int col) const
@ -896,7 +898,7 @@ wxString SearchListModel::GetColumnType(unsigned int col) const
void SearchListModel::GetValueByRow(wxVariant &variant, unsigned int row, unsigned int col) const
{
switch (col) {
case colIcon: variant << m_icon[m_values[row].second].bmp().GetBitmapFor(m_icon[m_values[row].second].parent()); break;
case colIcon: variant << m_icon[m_values[row].second].bmp(); break;
case colMarkedText: variant = m_values[row].first; break;
case colMax: wxFAIL_MSG("invalid column");
default: break;

View file

@ -270,7 +270,7 @@ public:
void Clear();
void Prepend(const std::string &text);
void sys_color_changed();
void msw_rescale();
// implementation of base class virtuals to define model

View file

@ -212,9 +212,9 @@ void MachineObjectPanel::doRender(wxDC &dc)
if (m_state == PrinterState::IN_LAN) { dwbitmap = m_printer_in_lan; }
// dc.DrawCircle(left, size.y / 2, 3);
dc.DrawBitmap(dwbitmap.get_bitmap(), wxPoint(left, (size.y - dwbitmap.GetSize().y) / 2));
dc.DrawBitmap(dwbitmap.bmp(), wxPoint(left, (size.y - dwbitmap.GetBmpSize().y) / 2));
left += dwbitmap.GetSize().x + 8;
left += dwbitmap.GetBmpSize().x + 8;
dc.SetFont(Label::Body_13);
dc.SetBackgroundMode(wxTRANSPARENT);
dc.SetTextForeground(StateColor::darkModeColorFor(SELECT_MACHINE_GREY900));
@ -230,10 +230,10 @@ void MachineObjectPanel::doRender(wxDC &dc)
auto text_end = 0;
if (m_show_edit) {
text_end = size.x - m_unbind_img.GetSize().x - 30;
text_end = size.x - m_unbind_img.GetBmpSize().x - 30;
}
else {
text_end = size.x - m_unbind_img.GetSize().x;
text_end = size.x - m_unbind_img.GetBmpSize().x;
}
wxString finally_name = dev_name;
@ -261,14 +261,14 @@ void MachineObjectPanel::doRender(wxDC &dc)
if (m_show_bind) {
if (m_bind_state == ALLOW_UNBIND) {
left = size.x - m_unbind_img.GetSize().x - 6;
dc.DrawBitmap(m_unbind_img.get_bitmap(), left, (size.y - m_unbind_img.GetSize().y) / 2);
left = size.x - m_unbind_img.GetBmpSize().x - 6;
dc.DrawBitmap(m_unbind_img.bmp(), left, (size.y - m_unbind_img.GetBmpSize().y) / 2);
}
}
if (m_show_edit) {
left = size.x - m_unbind_img.GetSize().x - 6 - m_edit_name_img.GetSize().x - 6;
dc.DrawBitmap(m_edit_name_img.get_bitmap(), left, (size.y - m_edit_name_img.GetSize().y) / 2);
left = size.x - m_unbind_img.GetBmpSize().x - 6 - m_edit_name_img.GetBmpSize().x - 6;
dc.DrawBitmap(m_edit_name_img.bmp(), left, (size.y - m_edit_name_img.GetBmpSize().y) / 2);
}
}
@ -298,10 +298,10 @@ void MachineObjectPanel::on_mouse_left_up(wxMouseEvent &evt)
if (m_is_my_devices) {
// show edit
if (m_show_edit) {
auto edit_left = GetSize().x - m_unbind_img.GetSize().x - 6 - m_edit_name_img.GetSize().x - 6;
auto edit_right = edit_left + m_edit_name_img.GetSize().x;
auto edit_top = (GetSize().y - m_edit_name_img.GetSize().y) / 2;
auto edit_bottom = (GetSize().y - m_edit_name_img.GetSize().y) / 2 + m_edit_name_img.GetSize().y;
auto edit_left = GetSize().x - m_unbind_img.GetBmpSize().x - 6 - m_edit_name_img.GetBmpSize().x - 6;
auto edit_right = edit_left + m_edit_name_img.GetBmpSize().x;
auto edit_top = (GetSize().y - m_edit_name_img.GetBmpSize().y) / 2;
auto edit_bottom = (GetSize().y - m_edit_name_img.GetBmpSize().y) / 2 + m_edit_name_img.GetBmpSize().y;
if ((evt.GetPosition().x >= edit_left && evt.GetPosition().x <= edit_right) && evt.GetPosition().y >= edit_top && evt.GetPosition().y <= edit_bottom) {
wxCommandEvent event(EVT_EDIT_PRINT_NAME);
event.SetEventObject(this);
@ -310,10 +310,10 @@ void MachineObjectPanel::on_mouse_left_up(wxMouseEvent &evt)
}
}
if (m_show_bind) {
auto left = GetSize().x - m_unbind_img.GetSize().x - 6;
auto right = left + m_unbind_img.GetSize().x;
auto top = (GetSize().y - m_unbind_img.GetSize().y) / 2;
auto bottom = (GetSize().y - m_unbind_img.GetSize().y) / 2 + m_unbind_img.GetSize().y;
auto left = GetSize().x - m_unbind_img.GetBmpSize().x - 6;
auto right = left + m_unbind_img.GetBmpSize().x;
auto top = (GetSize().y - m_unbind_img.GetBmpSize().y) / 2;
auto bottom = (GetSize().y - m_unbind_img.GetBmpSize().y) / 2 + m_unbind_img.GetBmpSize().y;
if ((evt.GetPosition().x >= left && evt.GetPosition().x <= right) && evt.GetPosition().y >= top && evt.GetPosition().y <= bottom) {
wxCommandEvent event(EVT_UNBIND_MACHINE, GetId());
@ -433,7 +433,7 @@ void SelectMachinePopup::Popup(wxWindow *WXUNUSED(focus))
if (wxGetApp().is_user_login()) {
if (!get_print_info_thread) {
get_print_info_thread = new boost::thread(Slic3r::create_thread([this, token = std::weak_ptr(m_token)] {
get_print_info_thread = new boost::thread(Slic3r::create_thread([this, token = std::weak_ptr<int>(m_token)] {
NetworkAgent* agent = wxGetApp().getAgent();
unsigned int http_code;
std::string body;
@ -2347,14 +2347,19 @@ bool SelectMachineDialog::is_same_printer_model()
const auto source_model = preset_bundle->printers.get_edited_preset().get_printer_type(preset_bundle);
const auto target_model = obj_->printer_type;
// Orca: ignore P1P -> P1S
if (source_model != target_model && !(preset_bundle->printers.get_edited_preset().get_printer_type(preset_bundle) == "C12") && !(target_model == "C11" && source_model == "C12")) {
if (source_model != target_model) {
if ((source_model == "C12" && target_model == "C11") || (source_model == "C11" && target_model == "C12") ||
(obj_->is_support_p1s_plus && (source_model == "C12"))) {
return true;
}
BOOST_LOG_TRIVIAL(info) << "printer_model: source = " << source_model;
BOOST_LOG_TRIVIAL(info) << "printer_model: target = " << target_model;
return false;
}
if (obj_->is_support_p1s_plus) {
BOOST_LOG_TRIVIAL(info) << "printer_model: source = " << preset_bundle->printers.get_edited_preset().get_printer_type(preset_bundle);
BOOST_LOG_TRIVIAL(info) << "printer_model: source = " << source_model;
BOOST_LOG_TRIVIAL(info) << "printer_model: target = " << obj_->printer_type << " (plus)";
return false;
}
@ -2477,7 +2482,7 @@ void SelectMachineDialog::on_ok_btn(wxCommandEvent &event)
std::string info;
DeviceManager::check_filaments_in_blacklist(filament_brand, filament_type, in_blacklist, action, info);
if (in_blacklist && action == "prohibition") {
has_prohibited_filament = true;
prohibited_error = wxString::FromUTF8(info);
@ -2513,12 +2518,12 @@ void SelectMachineDialog::on_ok_btn(wxCommandEvent &event)
if (!is_same_nozzle_diameters(tag_nozzle_type, nozzle_diameter)) {
has_slice_warnings = true;
has_update_nozzle = true;
wxString nozzle_in_preset = wxString::Format(_L("nozzle in preset: %s %s"),nozzle_diameter, "");
wxString nozzle_in_printer = wxString::Format(_L("nozzle memorized: %.1f %s"), obj_->nozzle_diameter, "");
confirm_text.push_back(_L("Your nozzle diameter in preset is not consistent with memorized nozzle diameter. Did you change your nozzle lately?")
+ "\n " + nozzle_in_preset
confirm_text.push_back(_L("Your nozzle diameter in preset is not consistent with memorized nozzle diameter. Did you change your nozzle lately?")
+ "\n " + nozzle_in_preset
+ "\n " + nozzle_in_printer
+ "\n");
}
@ -2531,7 +2536,7 @@ void SelectMachineDialog::on_ok_btn(wxCommandEvent &event)
confirm_text.push_back(nozzle_in_preset + "\n");
}
}
if (has_slice_warnings) {
wxString confirm_title = _L("Warning");
@ -2553,11 +2558,11 @@ void SelectMachineDialog::on_ok_btn(wxCommandEvent &event)
if (obj_ && !tag_nozzle_type.empty() && !nozzle_diameter.empty()) {
try
{
float diameter = std::stof(nozzle_diameter);
float diameter = std::stof(nozzle_diameter);
diameter = round(diameter * 10) / 10;
obj_->command_set_printer_nozzle(tag_nozzle_type, diameter);
}
catch (...) {}
catch (...) {}
}
});
@ -2833,7 +2838,7 @@ void SelectMachineDialog::update_user_machine_list()
{
NetworkAgent* m_agent = wxGetApp().getAgent();
if (m_agent && m_agent->is_user_login()) {
boost::thread get_print_info_thread = Slic3r::create_thread([this, token = std::weak_ptr(m_token)] {
boost::thread get_print_info_thread = Slic3r::create_thread([this, token = std::weak_ptr<int>(m_token)] {
NetworkAgent* agent = wxGetApp().getAgent();
unsigned int http_code;
std::string body;
@ -3631,16 +3636,16 @@ void SelectMachineDialog::Enable_Send_Button(bool en)
void SelectMachineDialog::on_dpi_changed(const wxRect &suggested_rect)
{
print_time->sys_color_changed();
print_time->msw_rescale();
timeimg->SetBitmap(print_time->bmp());
print_weight->sys_color_changed();
print_weight->msw_rescale();
weightimg->SetBitmap(print_weight->bmp());
m_rename_button->sys_color_changed();
ams_editable->sys_color_changed();
ams_editable_light->sys_color_changed();
enable_ams_mapping->sys_color_changed();
m_rename_button->msw_rescale();
ams_editable->msw_rescale();
ams_editable_light->msw_rescale();
enable_ams_mapping->msw_rescale();
img_amsmapping_tip->SetBitmap(enable_ams_mapping->bmp());
enable_ams->sys_color_changed();
enable_ams->msw_rescale();
img_use_ams_tip->SetBitmap(enable_ams->bmp());
m_button_refresh->SetMinSize(SELECT_MACHINE_DIALOG_BUTTON_SIZE);
@ -3806,7 +3811,7 @@ void SelectMachineDialog::set_default()
else if (m_print_type == PrintFromType::FROM_SDCARD_VIEW) {
set_default_from_sdcard();
}
Layout();
Fit();
}
@ -3836,14 +3841,14 @@ void SelectMachineDialog::set_default_normal()
std::vector<std::string> display_materials;
std::vector<std::string> m_filaments_id;
auto preset_bundle = wxGetApp().preset_bundle;
for (auto filament_name : preset_bundle->filament_presets) {
for (int f_index = 0; f_index < preset_bundle->filaments.size(); f_index++) {
PresetCollection* filament_presets = &wxGetApp().preset_bundle->filaments;
Preset* preset = &filament_presets->preset(f_index);
if (preset && filament_name.compare(preset->name) == 0) {
std::string display_filament_type;
std::string filament_type = preset->config.get_filament_type(display_filament_type);
@ -3865,7 +3870,7 @@ void SelectMachineDialog::set_default_normal()
//init MaterialItem
auto extruders = wxGetApp().plater()->get_partplate_list().get_curr_plate()->get_used_extruders();
MaterialHash::iterator iter = m_materialList.begin();
while (iter != m_materialList.end()) {
int id = iter->first;
@ -3914,7 +3919,7 @@ void SelectMachineDialog::set_default_normal()
DeviceManager* dev_manager = Slic3r::GUI::wxGetApp().getDeviceManager();
if (!dev_manager) return;
MachineObject* obj_ = dev_manager->get_selected_machine();
if (obj_ && obj_->is_support_ams_mapping()) {
if (m_mapping_popup.IsShown()) return;
wxPoint pos = item->ClientToScreen(wxPoint(0, 0));
@ -4437,12 +4442,12 @@ void EditDevNameDialog::on_edit_name(wxCommandEvent &e)
void ThumbnailPanel::set_thumbnail(wxImage img)
{
m_bitmap = img;
m_bitmap = img;
//Paint the background bitmap to the thumbnail bitmap with wxMemoryDC
wxMemoryDC dc;
bitmap_with_background.Create(wxSize(m_bitmap.GetWidth(), m_bitmap.GetHeight()));
dc.SelectObject(bitmap_with_background);
dc.DrawBitmap(m_background_bitmap.get_bitmap(), 0, 0);
dc.DrawBitmap(m_background_bitmap.bmp(), 0, 0);
dc.DrawBitmap(m_bitmap, 0, 0);
dc.SelectObject(wxNullBitmap);
@ -4455,7 +4460,7 @@ void EditDevNameDialog::on_edit_name(wxCommandEvent &e)
}
void ThumbnailPanel::render(wxDC& dc) {
if (wxGetApp().dark_mode()) {
#ifdef __WXMSW__
wxMemoryDC memdc;
@ -4469,7 +4474,7 @@ void EditDevNameDialog::on_edit_name(wxCommandEvent &e)
}
else
dc.DrawBitmap(m_bitmap, 0, 0);
}
ThumbnailPanel::~ThumbnailPanel() {}

View file

@ -813,7 +813,7 @@ void SendToPrinterDialog::update_user_machine_list()
{
NetworkAgent* m_agent = wxGetApp().getAgent();
if (m_agent && m_agent->is_user_login()) {
boost::thread get_print_info_thread = Slic3r::create_thread([this, token = std::weak_ptr(m_token)] {
boost::thread get_print_info_thread = Slic3r::create_thread([this, token = std::weak_ptr<int>(m_token)] {
NetworkAgent* agent = wxGetApp().getAgent();
unsigned int http_code;
std::string body;
@ -1391,4 +1391,4 @@ SendToPrinterDialog::~SendToPrinterDialog()
}
}
}
}

View file

@ -271,7 +271,7 @@ void PrintingTaskPanel::create_panel(wxWindow* parent)
bSizer_task_btn->Add(FromDIP(10), 0, 0);
m_button_pause_resume = new ScalableButton(m_panel_progress, wxID_ANY, "print_control_pause", wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER);
m_button_pause_resume = new ScalableButton(m_panel_progress, wxID_ANY, "print_control_pause", wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER,true);
m_button_pause_resume->Bind(wxEVT_ENTER_WINDOW, [this](auto &e) {
if (m_button_pause_resume->GetToolTipText() == _L("Pause")) {
@ -294,7 +294,7 @@ void PrintingTaskPanel::create_panel(wxWindow* parent)
}
});
m_button_abort = new ScalableButton(m_panel_progress, wxID_ANY, "print_control_stop", wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER);
m_button_abort = new ScalableButton(m_panel_progress, wxID_ANY, "print_control_stop", wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER, true);
m_button_abort->SetToolTip(_L("Stop"));
m_button_abort->Bind(wxEVT_ENTER_WINDOW, [this](auto &e) {
@ -498,7 +498,7 @@ void PrintingTaskPanel::create_panel(wxWindow* parent)
m_score_star.resize(5);
for (int i = 0; i < m_score_star.size(); ++i) {
m_score_star[i] = new ScalableButton(m_score_subtask_info, wxID_ANY, "score_star_dark", wxEmptyString, wxSize(FromDIP(26), FromDIP(26)), wxDefaultPosition,
wxBU_EXACTFIT | wxNO_BORDER, 26);
wxBU_EXACTFIT | wxNO_BORDER, true, 26);
m_score_star[i]->Bind(wxEVT_LEFT_DOWN, [this, i](auto &e) {
for (int j = 0; j < m_score_star.size(); ++j) {
ScalableBitmap light_star = ScalableBitmap(nullptr, "score_star_light", 26);
@ -555,7 +555,7 @@ void PrintingTaskPanel::paint(wxPaintEvent&)
{
wxPaintDC dc(m_bitmap_thumbnail);
if (wxGetApp().dark_mode())
dc.DrawBitmap(m_bitmap_background.get_bitmap(), 0, 0);
dc.DrawBitmap(m_bitmap_background.bmp(), 0, 0);
dc.DrawBitmap(m_thumbnail_bmp_display, wxPoint(0, 0));
dc.SetTextForeground(*wxBLACK);
dc.SetFont(Label::Body_12);
@ -583,7 +583,7 @@ void PrintingTaskPanel::msw_rescale()
//m_staticText_printing->SetMinSize(wxSize(PAGE_TITLE_TEXT_WIDTH, PAGE_TITLE_HEIGHT));
m_gauge_progress->SetHeight(PROGRESSBAR_HEIGHT);
m_gauge_progress->Rescale();
m_button_abort->sys_color_changed();
m_button_abort->msw_rescale();
m_bitmap_thumbnail->SetSize(TASK_THUMBNAIL_SIZE);
}
@ -619,7 +619,7 @@ void PrintingTaskPanel::show_error_msg(wxString msg)
void PrintingTaskPanel::reset_printing_value()
{
this->set_thumbnail_img(m_thumbnail_placeholder.get_bitmap());
this->set_thumbnail_img(m_thumbnail_placeholder.bmp());
this->set_plate_index(-1);
}
@ -1920,7 +1920,7 @@ void StatusPanel::on_webrequest_state(wxWebRequestEvent &evt)
case wxWebRequest::State_Failed:
case wxWebRequest::State_Cancelled:
case wxWebRequest::State_Unauthorized: {
m_project_task_panel->set_thumbnail_img(m_thumbnail_brokenimg.get_bitmap());
m_project_task_panel->set_thumbnail_img(m_thumbnail_brokenimg.bmp());
m_project_task_panel->set_plate_index(-1);
task_thumbnail_state = ThumbnailState::BROKEN_IMG;
break;
@ -4046,8 +4046,8 @@ void StatusPanel::rescale_camera_icons()
void StatusPanel::on_sys_color_changed()
{
m_project_task_panel->msw_rescale();
m_bitmap_speed.sys_color_changed();
m_bitmap_speed_active.sys_color_changed();
m_bitmap_speed.msw_rescale();
m_bitmap_speed_active.msw_rescale();
m_switch_speed->SetImages(m_bitmap_speed, m_bitmap_speed);
m_ams_control->msw_rescale();
if (m_print_error_dlg) { m_print_error_dlg->msw_rescale(); }
@ -4086,8 +4086,8 @@ void StatusPanel::msw_rescale()
m_tempCtrl_chamber->SetMinSize(TEMP_CTRL_MIN_SIZE);
m_tempCtrl_chamber->Rescale();
m_bitmap_speed.sys_color_changed();
m_bitmap_speed_active.sys_color_changed();
m_bitmap_speed.msw_rescale();
m_bitmap_speed_active.msw_rescale();
m_switch_speed->SetImages(m_bitmap_speed, m_bitmap_speed);
m_switch_speed->SetMinSize(MISC_BUTTON_2FAN_SIZE);
@ -4352,10 +4352,10 @@ wxBoxSizer *ScoreDialog::get_star_sizer()
}
if (i < m_star_count) {
m_score_star[i] = new ScalableButton(this, wxID_ANY, "score_star_light", wxEmptyString, wxSize(FromDIP(26), FromDIP(26)), wxDefaultPosition,
wxBU_EXACTFIT | wxNO_BORDER, 26);
wxBU_EXACTFIT | wxNO_BORDER, true, 26);
} else
m_score_star[i] = new ScalableButton(this, wxID_ANY, "score_star_dark", wxEmptyString, wxSize(FromDIP(26), FromDIP(26)), wxDefaultPosition,
wxBU_EXACTFIT | wxNO_BORDER, 26);
wxBU_EXACTFIT | wxNO_BORDER, true, 26);
m_score_star[i]->Bind(wxEVT_LEFT_DOWN, [this, i](auto &e) {
if (!m_success_printed && i >= 3) {

View file

@ -95,8 +95,8 @@ SysInfoDialog::SysInfoDialog()
main_sizer->Add(hsizer, 1, wxEXPAND | wxALL, 10);
// logo
m_logo = new wxStaticBitmap(this, wxID_ANY, *get_bmp_bundle(wxGetApp().logo_name(), 192));
m_logo_bmp = ScalableBitmap(this, wxGetApp().logo_name(), 192);
m_logo = new wxStaticBitmap(this, wxID_ANY, m_logo_bmp.bmp());
hsizer->Add(m_logo, 0, wxALIGN_CENTER_VERTICAL);
wxBoxSizer* vsizer = new wxBoxSizer(wxVERTICAL);

View file

@ -26,6 +26,7 @@
#include <boost/algorithm/string/predicate.hpp>
#include <boost/algorithm/string/replace.hpp>
#include "libslic3r/libslic3r.h"
#include "wxExtensions.hpp"
#include "PresetComboBoxes.hpp"
#include <wx/wupdlock.h>
@ -230,6 +231,8 @@ void Tab::create_preset_tab()
// add_scaled_button(panel, &m_btn_edit_ph_printer, "cog");
m_show_incompatible_presets = false;
add_scaled_bitmap(this, m_bmp_show_incompatible_presets, "flag_red");
add_scaled_bitmap(this, m_bmp_hide_incompatible_presets, "flag_green");
//add_scaled_button(panel, &m_btn_hide_incompatible_presets, m_bmp_hide_incompatible_presets.name());
@ -396,7 +399,7 @@ void Tab::create_preset_tab()
#endif
m_mode_sizer = new ModeSizer(panel, int (0.5*em_unit(this)));
const float scale_factor = em_unit(this)*0.1;// GetContentScaleFactor();
const float scale_factor = /*wxGetApp().*/em_unit(this)*0.1;// GetContentScaleFactor();
m_hsizer = new wxBoxSizer(wxHORIZONTAL);
sizer->Add(m_hsizer, 0, wxEXPAND | wxBOTTOM, 3);
m_hsizer->Add(m_presets_choice, 0, wxLEFT | wxRIGHT | wxTOP | wxALIGN_CENTER_VERTICAL, 3);
@ -445,8 +448,11 @@ void Tab::create_preset_tab()
m_tabctrl->Bind(wxEVT_RIGHT_DOWN, [this](auto &e) {}); // disable right select
m_tabctrl->SetFont(Label::Body_14);
//m_left_sizer->Add(m_tabctrl, 1, wxEXPAND);
// Index of the last icon inserted into m_tabctrl.
const int img_sz = int(32 * scale_factor + 0.5f);
m_icons = new wxImageList(img_sz, img_sz, false, 1);
// Index of the last icon inserted into $self->{icons}.
m_icon_count = -1;
m_tabctrl->AssignImageList(m_icons);
wxGetApp().UpdateDarkUI(m_tabctrl);
// Delay processing of the following handler until the message queue is flushed.
@ -524,22 +530,6 @@ void Tab::create_preset_tab()
// Initialize the DynamicPrintConfig by default keys/values.
build();
// Orca: shouldn't be needed bc TabCtrl doesn't use images passed through
// If needed, updated code is below. SetImages will need to be implemented in TabCtrl
// which should be easiest by adding wxWithImages mixin.
// This instance was added by PS when updating wx
/* if (!m_scaled_icons_list.empty()) {
// update icons for tree_ctrl
wxVector <wxBitmapBundle> img_bundles;
for (ScalableBitmap& bmp : m_scaled_icons_list) {
bmp.sys_color_changed();
img_bundles.push_back(bmp.bmp());
}
m_tabctrl->SetImages(img_bundles);
}*/
// ys_FIXME: Following should not be needed, the function will be called later
// (update_mode->update_visibility->rebuild_page_tree). This does not work, during the
// second call of rebuild_page_tree m_tabctrl->GetFirstVisibleItem(); returns zero
@ -555,7 +545,7 @@ void Tab::add_scaled_button(wxWindow* parent,
const wxString& label/* = wxEmptyString*/,
long style /*= wxBU_EXACTFIT | wxNO_BORDER*/)
{
*btn = new ScalableButton(parent, wxID_ANY, icon_name, label, wxDefaultSize, wxDefaultPosition, style);
*btn = new ScalableButton(parent, wxID_ANY, icon_name, label, wxDefaultSize, wxDefaultPosition, style, true);
(*btn)->SetBackgroundColour(parent->GetBackgroundColour());
m_scaled_buttons.push_back(*btn);
}
@ -586,6 +576,7 @@ Slic3r::GUI::PageShp Tab::add_options_page(const wxString& title, const std::str
if (icon_idx == -1) {
// Add a new icon to the icon list.
m_scaled_icons_list.push_back(ScalableBitmap(this, icon, 32, false, true));
//m_icons->Add(m_scaled_icons_list.back().bmp());
icon_idx = ++m_icon_count;
m_icon_index[icon] = icon_idx;
}
@ -910,6 +901,18 @@ void TabPrinter::init_options_list()
m_options_list.emplace("extruders_count", m_opt_status_value);
}
void TabPrinter::msw_rescale()
{
Tab::msw_rescale();
if (m_reset_to_filament_color)
m_reset_to_filament_color->msw_rescale();
//BBS: GUI refactor
//Layout();
m_parent->Layout();
}
void TabSLAMaterial::init_options_list()
{
if (!m_options_list.empty())
@ -1185,30 +1188,35 @@ void Tab::msw_rescale()
m_top_sizer->SetMinSize(-1, 3 * m_em_unit);
//BBS: GUI refactor
//if (m_mode_sizer)
// m_mode_sizer->msw_rescale();
if (m_presets_choice)
m_presets_choice->msw_rescale();
m_tabctrl->SetMinSize(wxSize(20 * m_em_unit, -1));
// rescale buttons and cached bitmaps
for (const auto btn : m_scaled_buttons)
btn->msw_rescale();
for (const auto bmp : m_scaled_bitmaps)
bmp->sys_color_changed();
bmp->msw_rescale();
if (m_mode_view)
m_mode_view->Rescale();
if (m_detach_preset_btn)
m_detach_preset_btn->sys_color_changed();
m_detach_preset_btn->msw_rescale();
// Orca: shouldn't be needed bc TabCtrl doesn't use images passed through
// If needed, updated code is below. SetImages will need to be implemented in TabCtrl
// which should be easiest by adding wxWithImages mixin.
/* // update icons for m_tabctrl
wxVector <wxBitmapBundle> img_bundles;
for (ScalableBitmap& bmp : m_scaled_icons_list) {
bmp.sys_color_changed();
img_bundles.push_back(bmp.bmp());
}
m_tabctrl->SetImages(img_bundles);*/
// rescale icons for tree_ctrl
for (ScalableBitmap& bmp : m_scaled_icons_list)
bmp.msw_rescale();
// recreate and set new ImageList for tree_ctrl
m_icons->RemoveAll();
m_icons = new wxImageList(m_scaled_icons_list.front().bmp().GetWidth(), m_scaled_icons_list.front().bmp().GetHeight(), false);
for (ScalableBitmap& bmp : m_scaled_icons_list)
//m_icons->Add(bmp.bmp());
m_tabctrl->AssignImageList(m_icons);
// rescale options_groups
if (m_active_page)
@ -1228,24 +1236,21 @@ void Tab::sys_color_changed()
// update buttons and cached bitmaps
for (const auto btn : m_scaled_buttons)
btn->sys_color_changed();
btn->msw_rescale();
for (const auto bmp : m_scaled_bitmaps)
bmp->sys_color_changed();
bmp->msw_rescale();
if (m_detach_preset_btn)
m_detach_preset_btn->sys_color_changed();
m_detach_preset_btn->msw_rescale();
update_show_hide_incompatible_button();
// Orca: shouldn't be needed bc TabCtrl doesn't use images passed through
// If needed, updated code is below. SetImages will need to be implemented in TabCtrl
// which should be easiest by adding wxWithImages mixin.
/* // update icons for m_tabctrl
wxVector <wxBitmapBundle> img_bundles;
for (ScalableBitmap& bmp : m_scaled_icons_list) {
bmp.sys_color_changed();
img_bundles.push_back(bmp.bmp());
}
m_tabctrl->SetImages(img_bundles);*/
// update icons for tree_ctrl
for (ScalableBitmap& bmp : m_scaled_icons_list)
bmp.msw_rescale();
// recreate and set new ImageList for tree_ctrl
m_icons->RemoveAll();
m_icons = new wxImageList(m_scaled_icons_list.front().bmp().GetWidth(), m_scaled_icons_list.front().bmp().GetHeight(), false);
for (ScalableBitmap& bmp : m_scaled_icons_list)
//m_icons->Add(bmp.bmp());
m_tabctrl->AssignImageList(m_icons);
// Colors for ui "decoration"
update_label_colours();
@ -1253,7 +1258,7 @@ void Tab::sys_color_changed()
wxWindowUpdateLocker noUpdates(this);
//BBS: GUI refactor
//if (m_mode_sizer)
// m_mode_sizer->sys_color_changed();
// m_mode_sizer->msw_rescale();
wxGetApp().UpdateDarkUI(this);
wxGetApp().UpdateDarkUI(m_tabctrl);
#endif
@ -1266,7 +1271,6 @@ void Tab::sys_color_changed()
//BBS: GUI refactor
//Layout();
m_parent->Layout();
m_parent->Refresh();
}
Field* Tab::get_field(const t_config_option_key& opt_key, int opt_index/* = -1*/) const
@ -1533,23 +1537,35 @@ void Tab::on_value_change(const std::string& opt_key, const boost::any& value)
auto max_layer_height_from_nozzle=wxGetApp().preset_bundle->full_config().option<ConfigOptionFloats>("max_layer_height")->values;
auto layer_height_floor = *std::min_element(min_layer_height_from_nozzle.begin(), min_layer_height_from_nozzle.end());
auto layer_height_ceil = *std::max_element(max_layer_height_from_nozzle.begin(), max_layer_height_from_nozzle.end());
bool exceed_minimum_flag = m_config->opt_float("layer_height") < layer_height_floor;
bool exceed_maximum_flag = m_config->opt_float("layer_height") > layer_height_ceil;
const auto lh = m_config->opt_float("layer_height");
bool exceed_minimum_flag = lh < layer_height_floor;
bool exceed_maximum_flag = lh > layer_height_ceil;
if (exceed_maximum_flag || exceed_minimum_flag) {
wxString msg_text = _(L("Layer height exceeds the limit in Printer Settings -> Extruder -> Layer height limits ,this may cause printing quality issues."));
msg_text += "\n\n" + _(L("Adjust to the set range automatically? \n"));
MessageDialog dialog(wxGetApp().plater(), msg_text, "", wxICON_WARNING | wxYES | wxNO);
dialog.SetButtonLabel(wxID_YES, _L("Adjust"));
dialog.SetButtonLabel(wxID_NO, _L("Ignore"));
auto answer = dialog.ShowModal();
auto new_conf = *m_config;
if (answer == wxID_YES) {
if (exceed_maximum_flag)
new_conf.set_key_value("layer_height", new ConfigOptionFloat(layer_height_ceil));
if (exceed_minimum_flag)
new_conf.set_key_value("layer_height",new ConfigOptionFloat(layer_height_floor));
if (lh < EPSILON) {
auto msg_text = _(L("Layer height is too small.\nIt will set to min_layer_height\n"));
MessageDialog dialog(wxGetApp().plater(), msg_text, "", wxICON_WARNING | wxOK);
dialog.SetButtonLabel(wxID_OK, _L("OK"));
dialog.ShowModal();
auto new_conf = *m_config;
new_conf.set_key_value("layer_height", new ConfigOptionFloat(layer_height_floor));
m_config_manipulation.apply(m_config, &new_conf);
} else {
wxString msg_text = _(L("Layer height exceeds the limit in Printer Settings -> Extruder -> Layer height limits ,this may "
"cause printing quality issues."));
msg_text += "\n\n" + _(L("Adjust to the set range automatically? \n"));
MessageDialog dialog(wxGetApp().plater(), msg_text, "", wxICON_WARNING | wxYES | wxNO);
dialog.SetButtonLabel(wxID_YES, _L("Adjust"));
dialog.SetButtonLabel(wxID_NO, _L("Ignore"));
auto answer = dialog.ShowModal();
auto new_conf = *m_config;
if (answer == wxID_YES) {
if (exceed_maximum_flag)
new_conf.set_key_value("layer_height", new ConfigOptionFloat(layer_height_ceil));
if (exceed_minimum_flag)
new_conf.set_key_value("layer_height", new ConfigOptionFloat(layer_height_floor));
m_config_manipulation.apply(m_config, &new_conf);
}
}
wxGetApp().plater()->update();
}
@ -1752,7 +1768,7 @@ void Tab::build_preset_description_line(ConfigOptionsGroup* optgroup)
auto detach_preset_btn = [this](wxWindow* parent) {
m_detach_preset_btn = new ScalableButton(parent, wxID_ANY, "lock_normal_sys", "",
wxDefaultSize, wxDefaultPosition, wxBU_LEFT | wxBU_EXACTFIT);
wxDefaultSize, wxDefaultPosition, wxBU_LEFT | wxBU_EXACTFIT, true);
ScalableButton* btn = m_detach_preset_btn;
btn->SetFont(Slic3r::GUI::wxGetApp().normal_font());
@ -1926,6 +1942,7 @@ void TabPrint::build()
optgroup->append_single_option_line("role_based_wipe_speed","seam");
optgroup->append_single_option_line("wipe_speed", "seam");
optgroup->append_single_option_line("wipe_on_loops","seam");
optgroup->append_single_option_line("wipe_before_external_loop","seam");
optgroup = page->new_optgroup(L("Precision"), L"param_precision");
@ -1991,6 +2008,7 @@ void TabPrint::build()
page = add_options_page(L("Strength"), "empty");
optgroup = page->new_optgroup(L("Walls"), L"param_wall");
optgroup->append_single_option_line("wall_loops");
optgroup->append_single_option_line("alternate_extra_wall");
optgroup->append_single_option_line("detect_thin_wall");
optgroup = page->new_optgroup(L("Top/bottom shells"), L"param_shell");
@ -2217,7 +2235,7 @@ void TabPrint::build()
optgroup->append_single_option_line(option);
#if 0
//page = add_options_page(L("Dependencies"), "advanced");
//page = add_options_page(L("Dependencies"), "advanced.png");
// optgroup = page->new_optgroup(L("Profile dependencies"));
// create_line_with_widget(optgroup.get(), "compatible_printers", "", [this](wxWindow* parent) {
@ -3680,7 +3698,7 @@ void TabPrinter::build_sla()
//optgroup->append_single_option_line("min_initial_exposure_time");
//optgroup->append_single_option_line("max_initial_exposure_time");
//page = add_options_page(L("Dependencies"), "wrench");
//page = add_options_page(L("Dependencies"), "wrench.png");
//optgroup = page->new_optgroup(L("Profile dependencies"));
//build_preset_description_line(optgroup.get());
@ -3753,6 +3771,8 @@ PageShp TabPrinter::build_kinematics_page()
optgroup->append_line(line);
}
auto optgroup = page->new_optgroup(L("Advanced"), "param_advanced");
optgroup->append_single_option_line("emit_machine_limits_to_gcode");
const std::vector<std::string> speed_axes{
"machine_max_speed_x",
@ -3760,7 +3780,7 @@ PageShp TabPrinter::build_kinematics_page()
"machine_max_speed_z",
"machine_max_speed_e"
};
auto optgroup = page->new_optgroup(L("Speed limitation"), "param_speed");
optgroup = page->new_optgroup(L("Speed limitation"), "param_speed");
for (const std::string &speed_axis : speed_axes) {
append_option_line(optgroup, speed_axis);
}
@ -3952,7 +3972,7 @@ if (is_marlin_flavor)
//auto reset_to_filament_color = [this, extruder_idx](wxWindow* parent) {
// m_reset_to_filament_color = new ScalableButton(parent, wxID_ANY, "undo", _L("Reset to Filament Color"),
// wxDefaultSize, wxDefaultPosition, wxBU_LEFT | wxBU_EXACTFIT);
// wxDefaultSize, wxDefaultPosition, wxBU_LEFT | wxBU_EXACTFIT, true);
// ScalableButton* btn = m_reset_to_filament_color;
// btn->SetFont(Slic3r::GUI::wxGetApp().normal_font());
// btn->SetSize(btn->GetBestSize());
@ -5315,7 +5335,8 @@ void Tab::toggle_show_hide_incompatible()
void Tab::update_show_hide_incompatible_button()
{
//BBS: GUI refactor
/*m_btn_hide_incompatible_presets->SetBitmap(*get_bmp_bundle(m_show_incompatible_presets ? "flag_red" : "flag_green"));
/*m_btn_hide_incompatible_presets->SetBitmap_(m_show_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.");*/
@ -5366,7 +5387,7 @@ wxSizer* Tab::compatible_widget_create(wxWindow* parent, PresetDependencies &dep
deps.checkbox->SetFont(Slic3r::GUI::wxGetApp().normal_font());
wxGetApp().UpdateDarkUI(deps.checkbox, false, true);
deps.btn = new ScalableButton(parent, wxID_ANY, "printer", from_u8((boost::format(" %s %s") % _utf8(L("Set")) % std::string(dots.ToUTF8())).str()),
wxDefaultSize, wxDefaultPosition, wxBU_LEFT | wxBU_EXACTFIT);
wxDefaultSize, wxDefaultPosition, wxBU_LEFT | wxBU_EXACTFIT, true);
deps.btn->SetFont(Slic3r::GUI::wxGetApp().normal_font());
deps.btn->SetSize(deps.btn->GetBestSize());
@ -5441,7 +5462,7 @@ wxSizer* Tab::compatible_widget_create(wxWindow* parent, PresetDependencies &dep
wxSizer* TabPrinter::create_bed_shape_widget(wxWindow* parent)
{
ScalableButton* btn = new ScalableButton(parent, wxID_ANY, "printer", " " + _(L("Set")) + " " + dots,
wxDefaultSize, wxDefaultPosition, wxBU_LEFT | wxBU_EXACTFIT);
wxDefaultSize, wxDefaultPosition, wxBU_LEFT | wxBU_EXACTFIT, true);
btn->SetFont(wxGetApp().normal_font());
btn->SetSize(btn->GetBestSize());
@ -5857,7 +5878,7 @@ void TabSLAMaterial::build()
//optgroup->append_line(line);
//page = add_options_page(L("Dependencies"), "wrench");
//page = add_options_page(L("Dependencies"), "wrench.png");
//optgroup = page->new_optgroup(L("Profile dependencies"));
//create_line_with_widget(optgroup.get(), "compatible_printers", "", [this](wxWindow* parent) {
@ -5878,7 +5899,7 @@ void TabSLAMaterial::build()
//build_preset_description_line(optgroup.get());
//page = add_options_page(L("Material printing profile"), "printer");
//page = add_options_page(L("Material printing profile"), "printer.png");
//optgroup = page->new_optgroup(L("Material printing profile"));
//option = optgroup->get_option("material_print_speed");
//optgroup->append_single_option_line(option);

View file

@ -154,6 +154,7 @@ protected:
//wxBoxSizer* m_hsizer;
//wxBoxSizer* m_left_sizer;
TabCtrl* m_tabctrl;
wxImageList* m_icons;
wxScrolledWindow* m_page_view {nullptr};
//wxBoxSizer* m_page_sizer {nullptr};
@ -188,6 +189,10 @@ protected:
StaticBox * m_search_item;
TextInput * m_search_input;
// Cached bitmaps.
// A "flag" icon to be displayned next to the preset name in the Tab's combo box.
ScalableBitmap m_bmp_show_incompatible_presets;
ScalableBitmap m_bmp_hide_incompatible_presets;
// Bitmaps to be shown on the "Revert to system" aka "Lock to system" button next to each input field.
ScalableBitmap m_bmp_value_lock;
ScalableBitmap m_bmp_value_unlock;
@ -615,6 +620,7 @@ public:
void build_unregular_pages(bool from_initial_build = false);
void on_preset_loaded() override;
void init_options_list() override;
void msw_rescale() override;
bool supports_printer_technology(const PrinterTechnology /* tech */) const override { return true; }
wxSizer* create_bed_shape_widget(wxWindow* parent);

View file

@ -148,7 +148,7 @@ void TabButton::render(wxDC &dc)
// BBS norrow size between text and icon
szContent.x += 5;
}
szIcon = icon.GetSize();
szIcon = icon.GetBmpSize();
szContent.x += szIcon.x;
if (szIcon.y > szContent.y) szContent.y = szIcon.y;
}
@ -169,9 +169,9 @@ void TabButton::render(wxDC &dc)
}
if (icon.bmp().IsOk()) {
pt.x = size.x - icon.GetWidth() - paddingSize.y;
pt.y = (size.y - icon.GetHeight()) / 2;
dc.DrawBitmap(icon.get_bitmap(), pt);
pt.x = size.x - icon.GetBmpWidth() - paddingSize.y;
pt.y = (size.y - icon.GetBmpHeight()) / 2;
dc.DrawBitmap(icon.bmp(), pt);
}
}
@ -189,7 +189,7 @@ void TabButton::messureSize()
// BBS norrow size between text and icon
szContent.x += 5;
}
wxSize szIcon = this->icon.GetSize();
wxSize szIcon = this->icon.GetBmpSize();
szContent.x += szIcon.x;
if (szIcon.y > szContent.y) szContent.y = szIcon.y;
}

View file

@ -117,21 +117,29 @@ wxIcon ModelNode::get_bitmap(const wxString& color)
wxBitmap ModelNode::get_bitmap(const wxString& color)
#endif // __linux__
{
wxBitmap bmp = get_solid_bmp_bundle(64, 16, into_u8(color))->GetBitmapFor(m_parent_win);
if (!m_toggle)
bmp = bmp.ConvertToDisabled();
/* It's supposed that standard size of an icon is 48px*16px for 100% scaled display.
* So set sizes for solid_colored icons used for filament preset
* and scale them in respect to em_unit value
*/
const double em = em_unit(m_parent_win);
const int icon_width = lround(6.4 * em);
const int icon_height = lround(1.6 * em);
BitmapCache bmp_cache;
ColorRGB rgb;
decode_color(into_u8(color), rgb);
// there is no need to scale created solid bitmap
#ifndef __linux__
return bmp;
return bmp_cache.mksolid(icon_width, icon_height, rgb, true);
#else
wxIcon icon;
icon.CopyFromBitmap(bmp);
icon.CopyFromBitmap(bmp_cache.mksolid(icon_width, icon_height, rgb, true));
return icon;
#endif // __linux__
}
// option node
ModelNode::ModelNode(ModelNode* parent, const wxString& text, const wxString& old_value, const wxString& new_value) :
m_parent_win(parent->m_parent_win),
m_parent(parent),
m_old_color(old_value.StartsWith("#") ? old_value : ""),
m_new_color(new_value.StartsWith("#") ? new_value : ""),
@ -196,22 +204,18 @@ void ModelNode::UpdateIcons()
{
// update icons for the colors, if any exists
if (!m_old_color.IsEmpty())
m_old_color_bmp = get_bitmap(m_old_color);
m_old_color_bmp = get_bitmap(m_toggle ? m_old_color : wxString::FromUTF8(grey.c_str()));
if (!m_new_color.IsEmpty())
m_new_color_bmp = get_bitmap(m_new_color);
m_new_color_bmp = get_bitmap(m_toggle ? m_new_color : wxString::FromUTF8(grey.c_str()));
// update main icon, if any exists
if (m_icon_name.empty())
return;
wxBitmap bmp = get_bmp_bundle(m_icon_name)->GetBitmapFor(m_parent_win);
if (!m_toggle)
bmp = bmp.ConvertToDisabled();
#ifdef __linux__
m_icon.CopyFromBitmap(bmp);
m_icon.CopyFromBitmap(create_scaled_bitmap(m_icon_name, m_parent_win, 16, !m_toggle));
#else
m_icon = bmp;
m_icon = create_scaled_bitmap(m_icon_name, m_parent_win, 16, !m_toggle);
#endif //__linux__
}
@ -1017,7 +1021,7 @@ void UnsavedChangesDialog::build(Preset::Type type, PresetCollection *dependent_
// "Save" button
if (ActionButtons::SAVE & m_buttons) add_btn(&m_save_btn, m_save_btn_id, "save", Action::Save, _L("Save"), false);
/* ScalableButton *cancel_btn = new ScalableButton(this, wxID_CANCEL, "cross", _L("Cancel"), wxDefaultSize, wxDefaultPosition, wxBORDER_DEFAULT, 24);
/* ScalableButton *cancel_btn = new ScalableButton(this, wxID_CANCEL, "cross", _L("Cancel"), wxDefaultSize, wxDefaultPosition, wxBORDER_DEFAULT, true, 24);
buttons->Add(cancel_btn, 1, wxLEFT | wxRIGHT, 5);
cancel_btn->SetFont(btn_font);*/
/* m_cancel_btn = new Button(this, _L("Cancel"));
@ -1704,7 +1708,7 @@ void UnsavedChangesDialog::on_dpi_changed(const wxRect& suggested_rect)
void UnsavedChangesDialog::on_sys_color_changed()
{
//for (auto btn : { m_save_btn, m_transfer_btn, m_discard_btn } )
//btn->sys_color_changed();
//btn->msw_rescale();
// msw_rescale updates just icons, so use it
//m_tree->Rescale();
@ -2111,16 +2115,10 @@ void DiffPresetDialog::on_dpi_changed(const wxRect&)
const wxSize& size = wxSize(80 * em, 30 * em);
SetMinSize(size);
auto rescale = [em](PresetComboBox* pcb) {
pcb->msw_rescale();
wxSize sz = wxSize(35 * em, -1);
pcb->SetMinSize(sz);
pcb->SetSize(sz);
};
for (auto preset_combos : m_preset_combos) {
rescale(preset_combos.presets_left);
rescale(preset_combos.presets_right);
preset_combos.presets_left->msw_rescale();
preset_combos.equal_bmp->msw_rescale();
preset_combos.presets_right->msw_rescale();
}
m_tree->Rescale(em);
@ -2138,9 +2136,9 @@ void DiffPresetDialog::on_sys_color_changed()
#endif
for (auto preset_combos : m_preset_combos) {
preset_combos.presets_left->sys_color_changed();
preset_combos.equal_bmp->sys_color_changed();
preset_combos.presets_right->sys_color_changed();
preset_combos.presets_left->msw_rescale();
preset_combos.equal_bmp->msw_rescale();
preset_combos.presets_right->msw_rescale();
}
// msw_rescale updates just icons, so use it
m_tree->Rescale();

View file

@ -341,15 +341,15 @@ void MachineInfoPanel::init_bitmaps()
void MachineInfoPanel::rescale_bitmaps()
{
m_img_printer.sys_color_changed();
m_img_printer.msw_rescale();
m_printer_img->SetBitmap(m_img_printer.bmp());
m_img_monitor_ams.sys_color_changed();
m_img_monitor_ams.msw_rescale();
m_ams_img->SetBitmap(m_img_monitor_ams.bmp());
m_img_ext.sys_color_changed();
m_img_ext.msw_rescale();
m_ext_img->SetBitmap(m_img_ext.bmp());
upgrade_green_icon.sys_color_changed();
upgrade_gray_icon.sys_color_changed();
upgrade_yellow_icon.sys_color_changed();
upgrade_green_icon.msw_rescale();
upgrade_gray_icon.msw_rescale();
upgrade_yellow_icon.msw_rescale();
m_ota_new_version_img->SetBitmap(upgrade_green_icon.bmp());
}
@ -1287,8 +1287,8 @@ bool UpgradePanel::Show(bool show)
}
void AmsPanel::msw_rescale() {
upgrade_green_icon.sys_color_changed();
void AmsPanel::msw_rescale() {
upgrade_green_icon.msw_rescale();
m_ams_new_version_img->SetBitmap(upgrade_green_icon.bmp());
}
@ -1361,8 +1361,8 @@ bool UpgradePanel::Show(bool show)
}
void ExtensionPanel::msw_rescale()
{
upgrade_green_icon.sys_color_changed();
{
upgrade_green_icon.msw_rescale();
m_ext_new_version_img->SetBitmap(upgrade_green_icon.bmp());
}

Some files were not shown because too many files have changed in this diff Show more