Add svg icons

This commit is contained in:
Filip Sykala - NTB T15p 2023-09-18 07:31:25 +02:00
parent 309ec878dd
commit 8bc828919c
9 changed files with 126 additions and 6 deletions

View File

@ -0,0 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16px" height="16px">
<path fill="#808080" d="M 1.5,3 C 0.47,3 0,3.5 0,4.5 v 10 C 0,15.36 0.63,16 1.5,16 h 10 c 0.86,0 1.5,-0.63 1.5,-1.5 V 13 h -1 v 1.5 C 12,14.8 11.79,15 11.5,15 H 1.5 C 1.17,15 1,14.7 1,14.5 L 1,4.5 C 1,4.18 1.2,4 1.5,4 H 8 C 8.35,4 8.5,3.78 8.5,3.5 8.5,3.2 8.3,3 8,3 Z M 5,7 4,8 v 1 l 1,1 h 1 v 1 H 4 v 1 H 6 L 7,11 V 10 L 6,9 H 5 V 8 H 7 V 7 Z m 3,0 v 4 H 9 V 7 Z m 1,4 v 1 h 1 v -1 z m 1,0 h 1 V 7 H 10 Z M 13.5,7 C 12.5,7 12,7.6 12,8.5 V 10.5 C 12,11.4 12.7,12 13.5,12 h 1.5 v -2 h -1 v 1 H 13.5 C 13.3,11 13,10.8 13,10.5 V 8.5 C 13,8 13.2,8 13.5,8 h 0 1.5 V 7 Z M 2,11 v 1 h 1 v -1 z" />
<path fill="#ed6b21" d="m 12.5,1 a 2.5,2.5 0 0 0 -2.5,2.5 2.5,2.5 0 0 0 2.5,2.5 2.5,2.5 0 0 0 2.5,-2.5 2.5,2.5 0 0 0 -2.5,-2.5 z m 0.144531,1 a 1.5,1.5 0 0 1 1.355469,1.355469 z m -0.632812,0 1.90625,2 a 1.5,1.5 0 0 1 -0.628906,0.773438 l -2,-2 a 1.5,1.5 0 0 1 0.7,-0.7 z m -1,1.2 1.78,1.78 a 1.5,1.5 0 0 1 -0.28125,0 1.5,1.5 0 0 1 -1.5,-1.5 1.5,1.5 0 0 1 0,-0.28125 z" />
</svg>

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
viewBox="0 0 16 16"
width="16px"
height="16px"
version="1.1"
id="svg6"
sodipodi:docname="svg_negative.svg"
xml:space="preserve"
inkscape:version="1.2 (dc2aedaf03, 2022-05-15)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"><defs
id="defs10" /><sodipodi:namedview
id="namedview8"
pagecolor="#ffffff"
bordercolor="#000000"
borderopacity="0.25"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
showgrid="true"
inkscape:zoom="71.064231"
inkscape:cx="9.7869207"
inkscape:cy="5.1432344"
inkscape:window-width="1920"
inkscape:window-height="991"
inkscape:window-x="-9"
inkscape:window-y="-9"
inkscape:window-maximized="1"
inkscape:current-layer="svg6"><inkscape:grid
type="xygrid"
id="grid309" /></sodipodi:namedview><path
fill="#808080"
d="M 1.5,3 C 0.47,3 0,3.5 0,4.5 v 10 C 0,15.36 0.63,16 1.5,16 h 10 c 0.86,0 1.5,-0.63 1.5,-1.5 V 13 h -1 v 1.5 C 12,14.8 11.79,15 11.5,15 H 1.5 C 1.17,15 1,14.7 1,14.5 L 1,4.5 C 1,4.18 1.2,4 1.5,4 H 8 C 8.35,4 8.5,3.78 8.5,3.5 8.5,3.2 8.3,3 8,3 Z M 5,7 4,8 v 1 l 1,1 h 1 v 1 H 4 v 1 H 6 L 7,11 V 10 L 6,9 H 5 V 8 H 7 V 7 Z m 3,0 v 4 H 9 V 7 Z m 1,4 v 1 h 1 v -1 z m 1,0 h 1 V 7 H 10 Z M 13.5,7 C 12.5,7 12,7.6 12,8.5 V 10.5 C 12,11.4 12.7,12 13.5,12 h 1.5 v -2 h -1 v 1 H 13.5 C 13.3,11 13,10.8 13,10.5 V 8.5 C 13,8 13.2,8 13.5,8 h 0 1.5 V 7 Z M 2,11 v 1 h 1 v -1 z"
id="path2" /><path
fill="#ed6b21"
d="M 11,3 C 10.5,3 10,3 10,3.5 10,4 10.5,4 11,4 h 3 C 14.5,4 15,4 15,3.5 15,3 14.5,3 14,3 Z"
id="path187" /></svg>

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
viewBox="0 0 16 16"
width="16px"
height="16px"
version="1.1"
id="svg6"
sodipodi:docname="svg_part.svg"
xml:space="preserve"
inkscape:version="1.2 (dc2aedaf03, 2022-05-15)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"><defs
id="defs10" /><sodipodi:namedview
id="namedview8"
pagecolor="#ffffff"
bordercolor="#000000"
borderopacity="0.25"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
showgrid="true"
inkscape:zoom="100.5"
inkscape:cx="16.402985"
inkscape:cy="4.4228856"
inkscape:window-width="1920"
inkscape:window-height="991"
inkscape:window-x="-9"
inkscape:window-y="-9"
inkscape:window-maximized="1"
inkscape:current-layer="svg6"><inkscape:grid
type="xygrid"
id="grid309" /></sodipodi:namedview><path
fill="#808080"
d="M 1.5,3 C 0.47,3 0,3.5 0,4.5 v 10 C 0,15.36 0.63,16 1.5,16 h 10 c 0.86,0 1.5,-0.63 1.5,-1.5 V 13 h -1 v 1.5 C 12,14.8 11.79,15 11.5,15 H 1.5 C 1.17,15 1,14.7 1,14.5 L 1,4.5 C 1,4.18 1.2,4 1.5,4 H 8 C 8.35,4 8.5,3.78 8.5,3.5 8.5,3.2 8.3,3 8,3 Z M 5,7 4,8 v 1 l 1,1 h 1 v 1 H 4 v 1 H 6 L 7,11 V 10 L 6,9 H 5 V 8 H 7 V 7 Z m 3,0 v 4 H 9 V 7 Z m 1,4 v 1 h 1 v -1 z m 1,0 h 1 V 7 H 10 Z M 13.5,7 C 12.5,7 12,7.6 12,8.5 V 10.5 C 12,11.4 12.7,12 13.5,12 h 1.5 v -2 h -1 v 1 H 13.5 C 13.3,11 13,10.8 13,10.5 V 8.5 C 13,8 13.2,8 13.5,8 h 0 1.5 V 7 Z M 2,11 v 1 h 1 v -1 z"
id="path2" /><path
fill="#ed6b21"
d="M 12.5,1 C 12,1 12,1.5 12,2 V 3 H 11 C 10.5,3 10,3 10,3.5 10,4 10.5,4 11,4 h 1 v 1 c 0,0.5 0,1 0.5,1 C 13,6 13,5.5 13,5 V 4 h 1 C 14.5,4 15,4 15,3.5 15,3 14.5,3 14,3 H 13 V 2 C 13,1.5 13,1 12.5,1 Z"
id="path183" /></svg>

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@ -845,6 +845,7 @@ public:
bool is_support_blocker() const { return m_type == ModelVolumeType::SUPPORT_BLOCKER; }
bool is_support_modifier() const { return m_type == ModelVolumeType::SUPPORT_BLOCKER || m_type == ModelVolumeType::SUPPORT_ENFORCER; }
bool is_text() const { return text_configuration.has_value(); }
bool is_svg() const { return emboss_shape.has_value() && !text_configuration.has_value(); }
bool is_the_only_one_part() const; // behave like an object
t_model_material_id material_id() const { return m_material_id; }
void reset_extra_facets();

View File

@ -175,6 +175,12 @@ static const constexpr std::array<std::pair<const char *, const char *>, 3> TEXT
{L("Add negative text"), "add_text_negative" }, // ~ModelVolumeType::NEGATIVE_VOLUME
{L("Add text modifier"), "add_text_modifier"}, // ~ModelVolumeType::PARAMETER_MODIFIER
}};
// Note: id accords to type of the sub-object (adding volume), so sequence of the menu items is important
static const constexpr std::array<std::pair<const char *, const char *>, 3> SVG_VOLUME_ICONS{{
{L("Add svg part"), "svg_part"}, // ~ModelVolumeType::MODEL_PART
{L("Add negative svg"), "svg_negative"}, // ~ModelVolumeType::NEGATIVE_VOLUME
{L("Add svg modifier"), "svg_modifier"}, // ~ModelVolumeType::PARAMETER_MODIFIER
}};
static Plater* plater()
{
@ -446,7 +452,7 @@ std::vector<wxBitmapBundle*> MenuFactory::get_volume_bitmaps()
{
std::vector<wxBitmapBundle*> volume_bmps;
volume_bmps.reserve(ADD_VOLUME_MENU_ITEMS.size());
for (auto item : ADD_VOLUME_MENU_ITEMS)
for (const auto& item : ADD_VOLUME_MENU_ITEMS)
volume_bmps.push_back(get_bmp_bundle(item.second));
return volume_bmps;
}
@ -455,7 +461,16 @@ std::vector<wxBitmapBundle*> MenuFactory::get_text_volume_bitmaps()
{
std::vector<wxBitmapBundle*> volume_bmps;
volume_bmps.reserve(TEXT_VOLUME_ICONS.size());
for (auto item : TEXT_VOLUME_ICONS)
for (const auto& item : TEXT_VOLUME_ICONS)
volume_bmps.push_back(get_bmp_bundle(item.second));
return volume_bmps;
}
std::vector<wxBitmapBundle*> MenuFactory::get_svg_volume_bitmaps()
{
std::vector<wxBitmapBundle *> 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));
return volume_bmps;
}

View File

@ -39,6 +39,7 @@ 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();
MenuFactory();
~MenuFactory() = default;

View File

@ -3054,6 +3054,7 @@ wxDataViewItemArray ObjectList::add_volumes_to_object_in_list(size_t obj_idx, st
volume_idx,
volume->type(),
volume->is_text(),
volume->is_svg(),
get_warning_icon_name(volume->mesh().stats()),
extruder2str(volume->config.has("extruder") ? volume->config.extruder() : 0));
add_settings_item(vol_item, &volume->config.get());

View File

@ -80,6 +80,7 @@ ObjectDataViewModelNode::ObjectDataViewModelNode(ObjectDataViewModelNode* pare
const wxString& sub_obj_name,
Slic3r::ModelVolumeType type,
const bool is_text_volume,
const bool is_svg_volume,
const wxString& extruder,
const int idx/* = -1*/) :
m_parent(parent),
@ -87,6 +88,7 @@ ObjectDataViewModelNode::ObjectDataViewModelNode(ObjectDataViewModelNode* pare
m_type(itVolume),
m_volume_type(type),
m_is_text_volume(is_text_volume),
m_is_svg_volume(is_svg_volume),
m_idx(idx),
m_extruder(type == Slic3r::ModelVolumeType::MODEL_PART || type == Slic3r::ModelVolumeType::PARAMETER_MODIFIER ? extruder : "")
{
@ -338,6 +340,7 @@ 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);
@ -360,7 +363,10 @@ void ObjectDataViewModel::UpdateBitmapForNode(ObjectDataViewModelNode* node)
bool is_volume_node = vol_type >= 0;
if (!node->has_warning_icon() && !node->has_lock()) {
node->SetBitmap(is_volume_node ? (node->is_text_volume() ? *m_text_volume_bmps.at(vol_type) : *m_volume_bmps.at(vol_type)) : m_empty_bmp);
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);
return;
}
@ -381,7 +387,10 @@ void ObjectDataViewModel::UpdateBitmapForNode(ObjectDataViewModelNode* node)
if (node->has_lock())
bmps.emplace_back(&m_lock_bmp);
if (is_volume_node)
bmps.emplace_back(node->is_text_volume() ? m_text_volume_bmps[vol_type] : m_volume_bmps[vol_type]);
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);
}
@ -418,6 +427,7 @@ wxDataViewItem ObjectDataViewModel::AddVolumeChild( const wxDataViewItem &parent
const int volume_idx,
const Slic3r::ModelVolumeType volume_type,
const bool is_text_volume,
const bool is_svg_volume,
const std::string& warning_icon_name,
const wxString& extruder)
{
@ -429,7 +439,7 @@ wxDataViewItem ObjectDataViewModel::AddVolumeChild( const wxDataViewItem &parent
if (insert_position < 0)
insert_position = get_root_idx(root, itInstanceRoot);
const auto node = new ObjectDataViewModelNode(root, name, volume_type, is_text_volume, extruder, volume_idx);
const auto node = new ObjectDataViewModelNode(root, name, volume_type, is_text_volume, is_svg_volume, extruder, volume_idx);
UpdateBitmapForNode(node, warning_icon_name, root->has_lock() && volume_type < ModelVolumeType::PARAMETER_MODIFIER);
insert_position < 0 ? root->Append(node) : root->Insert(node, insert_position);
@ -1688,6 +1698,7 @@ void ObjectDataViewModel::UpdateBitmaps()
{
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);

View File

@ -89,6 +89,7 @@ class ObjectDataViewModelNode
std::string m_action_icon_name = "";
ModelVolumeType m_volume_type{ -1 };
bool m_is_text_volume{ false };
bool m_is_svg_volume{false};
InfoItemType m_info_item_type {InfoItemType::Undef};
public:
@ -107,6 +108,7 @@ public:
const wxString& sub_obj_name,
Slic3r::ModelVolumeType type,
const bool is_text_volume,
const bool is_svg_volume,
const wxString& extruder,
const int idx = -1 );
@ -242,6 +244,7 @@ public:
bool update_settings_digest(const std::vector<std::string>& categories);
int volume_type() const { return int(m_volume_type); }
bool is_text_volume() const { return m_is_text_volume; }
bool is_svg_volume() const { return m_is_svg_volume; }
void sys_color_changed();
#ifndef NDEBUG
@ -269,6 +272,7 @@ class ObjectDataViewModel :public wxDataViewModel
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;
@ -290,6 +294,7 @@ public:
const int volume_idx,
const Slic3r::ModelVolumeType volume_type,
const bool is_text_volume,
const bool is_svg_volume,
const std::string& warning_icon_name,
const wxString& extruder);
wxDataViewItem AddSettingsChild(const wxDataViewItem &parent_item);