mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-07-30 22:52:01 +08:00
Code refactoring: Rivet is changed to Snap
This commit is contained in:
parent
e4fde63c47
commit
e8bdd9e78d
@ -3,11 +3,11 @@
|
||||
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
width="16px" height="16px" viewBox="0 0 16 16" style="enable-background:new 0 0 16 16;" xml:space="preserve">
|
||||
<g>
|
||||
<path fill="#ED6B21" d="M9,15H7c-0.5522847,0-1-0.4477148-1-1V5c0-0.5522847,0.4477153-1,1-1h2c0.5522852,0,1,0.4477153,1,1v9
|
||||
<path fill="#808080" d="M9,15H7c-0.5522847,0-1-0.4477148-1-1V5c0-0.5522847,0.4477153-1,1-1h2c0.5522852,0,1,0.4477153,1,1v9
|
||||
C10,14.5522852,9.5522852,15,9,15z"/>
|
||||
</g>
|
||||
<g>
|
||||
<path fill="none" stroke="#808080" stroke-linecap="round" stroke-miterlimit="5" d="M1.5,11.5h2v-8c0-1.1045694,0.8954306-2,2-2h5c1.1045694,0,2,0.8954306,2,2v8h2"/>
|
||||
<path fill="none" stroke="#ED6B21" stroke-linecap="round" stroke-miterlimit="5" d="M1.5,11.5h2v-8c0-1.1045694,0.8954306-2,2-2h5c1.1045694,0,2,0.8954306,2,2v8h2"/>
|
||||
</g>
|
||||
<line fill="none" stroke="#ED6B21" stroke-linecap="round" stroke-miterlimit="10" x1="1.5" y1="14.5" x2="14.5" y2="14.5"/>
|
||||
<line fill="none" stroke="#808080" stroke-linecap="round" stroke-miterlimit="10" x1="1.5" y1="14.5" x2="14.5" y2="14.5"/>
|
||||
</svg>
|
Before Width: | Height: | Size: 846 B After Width: | Height: | Size: 846 B |
@ -152,7 +152,7 @@ namespace ImGui
|
||||
// const wchar_t MmuSegmentationMarker = 0x1F;
|
||||
const wchar_t PlugMarker = 0x1C;
|
||||
const wchar_t DowelMarker = 0x1D;
|
||||
const wchar_t RivetMarker = 0x1E;
|
||||
const wchar_t SnapMarker = 0x1E;
|
||||
// Do not forget use following letters only in wstring
|
||||
const wchar_t DocumentationButton = 0x2600;
|
||||
const wchar_t DocumentationHoverButton = 0x2601;
|
||||
|
@ -1356,7 +1356,7 @@ void ModelVolume::apply_tolerance()
|
||||
|
||||
double z_offset = 0.5 * static_cast<double>(cut_info.height_tolerance);
|
||||
if (cut_info.connector_type == CutConnectorType::Plug ||
|
||||
cut_info.connector_type == CutConnectorType::Rivet)
|
||||
cut_info.connector_type == CutConnectorType::Snap)
|
||||
z_offset -= 0.05; // add small Z offset to better preview
|
||||
|
||||
set_offset(get_offset() + rot_norm * z_offset);
|
||||
@ -1394,7 +1394,7 @@ void ModelObject::process_connector_cut(ModelVolume* volume, const Transform3d&
|
||||
if (volume->cut_info.connector_type != CutConnectorType::Dowel) {
|
||||
if (attributes.has(ModelObjectCutAttribute::KeepUpper)) {
|
||||
ModelVolume* vol = nullptr;
|
||||
if (volume->cut_info.connector_type == CutConnectorType::Rivet) {
|
||||
if (volume->cut_info.connector_type == CutConnectorType::Snap) {
|
||||
TriangleMesh mesh = TriangleMesh(its_make_cylinder(1.0, 1.0, PI / 180.));
|
||||
|
||||
vol = upper->add_volume(std::move(mesh));
|
||||
|
@ -224,7 +224,7 @@ private:
|
||||
enum class CutConnectorType : int {
|
||||
Plug
|
||||
, Dowel
|
||||
, Rivet
|
||||
, Snap
|
||||
, Undef
|
||||
};
|
||||
|
||||
@ -240,7 +240,6 @@ enum class CutConnectorShape : int {
|
||||
, Square
|
||||
, Hexagon
|
||||
, Circle
|
||||
, Rivet
|
||||
, Undef
|
||||
//,D-shape
|
||||
};
|
||||
|
@ -186,7 +186,7 @@ GLGizmoCut3D::GLGizmoCut3D(GLCanvas3D& parent, const std::string& icon_filename,
|
||||
, m_connector_style (int(CutConnectorStyle::Prism))
|
||||
, m_connector_shape_id (int(CutConnectorShape::Circle))
|
||||
{
|
||||
m_connector_type = CutConnectorType::Rivet;
|
||||
m_connector_type = CutConnectorType::Snap;
|
||||
|
||||
m_modes = { _u8L("Planar"), _u8L("Tongue and Groove")//, _u8L("Grid")
|
||||
// , _u8L("Radial"), _u8L("Modular")
|
||||
@ -197,7 +197,7 @@ GLGizmoCut3D::GLGizmoCut3D(GLCanvas3D& parent, const std::string& icon_filename,
|
||||
std::map<const wchar_t, std::string> connetor_types = {
|
||||
{ImGui::PlugMarker , _u8L("Plug") },
|
||||
{ImGui::DowelMarker, _u8L("Dowel") },
|
||||
{ImGui::RivetMarker, _u8L("Rivet") },
|
||||
{ImGui::SnapMarker, _u8L("Snap") },
|
||||
};
|
||||
for (auto connector : connetor_types) {
|
||||
std::string type_label = " " + connector.second + " ";
|
||||
@ -2191,7 +2191,7 @@ void GLGizmoCut3D::render_connectors_input_window(CutConnectors &connectors)
|
||||
m_imgui->text(m_labels_map["Type"]);
|
||||
bool type_changed = render_connect_type_radio_button(CutConnectorType::Plug);
|
||||
type_changed |= render_connect_type_radio_button(CutConnectorType::Dowel);
|
||||
type_changed |= render_connect_type_radio_button(CutConnectorType::Rivet);
|
||||
type_changed |= render_connect_type_radio_button(CutConnectorType::Snap);
|
||||
if (type_changed)
|
||||
apply_selected_connectors([this, &connectors] (size_t idx) { connectors[idx].attribs.type = CutConnectorType(m_connector_type); });
|
||||
|
||||
@ -2204,8 +2204,8 @@ void GLGizmoCut3D::render_connectors_input_window(CutConnectors &connectors)
|
||||
apply_selected_connectors([this, &connectors](size_t idx) { connectors[idx].attribs.style = CutConnectorStyle(m_connector_style); });
|
||||
m_imgui->disabled_end();
|
||||
|
||||
m_imgui->disabled_begin(m_connector_type == CutConnectorType::Rivet);
|
||||
if (type_changed && m_connector_type == CutConnectorType::Rivet) {
|
||||
m_imgui->disabled_begin(m_connector_type == CutConnectorType::Snap);
|
||||
if (type_changed && m_connector_type == CutConnectorType::Snap) {
|
||||
m_connector_shape_id = int(CutConnectorShape::Circle);
|
||||
apply_selected_connectors([this, &connectors](size_t idx) { connectors[idx].attribs.shape = CutConnectorShape(m_connector_shape_id); });
|
||||
}
|
||||
@ -2213,7 +2213,7 @@ void GLGizmoCut3D::render_connectors_input_window(CutConnectors &connectors)
|
||||
apply_selected_connectors([this, &connectors](size_t idx) { connectors[idx].attribs.shape = CutConnectorShape(m_connector_shape_id); });
|
||||
m_imgui->disabled_end();
|
||||
|
||||
const float depth_min_value = m_connector_type == CutConnectorType::Rivet ? m_connector_size : -0.1f;
|
||||
const float depth_min_value = m_connector_type == CutConnectorType::Snap ? m_connector_size : -0.1f;
|
||||
if (render_slider_double_input(m_labels_map["Depth"], m_connector_depth_ratio, m_connector_depth_ratio_tolerance, depth_min_value))
|
||||
apply_selected_connectors([this, &connectors](size_t idx) {
|
||||
if (m_connector_depth_ratio > 0)
|
||||
@ -2230,7 +2230,7 @@ void GLGizmoCut3D::render_connectors_input_window(CutConnectors &connectors)
|
||||
connectors[idx].radius_tolerance = 0.5f * m_connector_size_tolerance;
|
||||
});
|
||||
|
||||
if (m_connector_type == CutConnectorType::Rivet) {
|
||||
if (m_connector_type == CutConnectorType::Snap) {
|
||||
|
||||
const std::string format = "%.0f %%";
|
||||
|
||||
@ -3508,12 +3508,12 @@ void GLGizmoCut3D::reset_connectors()
|
||||
|
||||
void GLGizmoCut3D::init_connector_shapes()
|
||||
{
|
||||
for (const CutConnectorType& type : {CutConnectorType::Dowel, CutConnectorType::Plug, CutConnectorType::Rivet})
|
||||
for (const CutConnectorType& type : {CutConnectorType::Dowel, CutConnectorType::Plug, CutConnectorType::Snap})
|
||||
for (const CutConnectorStyle& style : {CutConnectorStyle::Frustum, CutConnectorStyle::Prism}) {
|
||||
if (type == CutConnectorType::Dowel && style == CutConnectorStyle::Frustum)
|
||||
continue;
|
||||
for (const CutConnectorShape& shape : {CutConnectorShape::Circle, CutConnectorShape::Hexagon, CutConnectorShape::Square, CutConnectorShape::Triangle}) {
|
||||
if (type == CutConnectorType::Rivet && shape != CutConnectorShape::Circle)
|
||||
if (type == CutConnectorType::Snap && shape != CutConnectorShape::Circle)
|
||||
continue;
|
||||
const CutConnectorAttributes attribs = { type, style, shape };
|
||||
indexed_triangle_set its = get_connector_mesh(attribs);
|
||||
@ -3527,7 +3527,7 @@ void GLGizmoCut3D::update_connector_shape()
|
||||
{
|
||||
CutConnectorAttributes attribs = { m_connector_type, CutConnectorStyle(m_connector_style), CutConnectorShape(m_connector_shape_id) };
|
||||
|
||||
if (m_connector_type == CutConnectorType::Rivet) {
|
||||
if (m_connector_type == CutConnectorType::Snap) {
|
||||
indexed_triangle_set its = get_connector_mesh(attribs);
|
||||
m_shapes[attribs].reset();
|
||||
m_shapes[attribs].model.init_from(its);
|
||||
@ -3822,7 +3822,7 @@ indexed_triangle_set GLGizmoCut3D::get_connector_mesh(CutConnectorAttributes con
|
||||
break;
|
||||
}
|
||||
|
||||
if (connector_attributes.type == CutConnectorType::Rivet)
|
||||
if (connector_attributes.type == CutConnectorType::Snap)
|
||||
connector_mesh = its_make_snap(1.0, 1.0, m_snap_space_proportion, m_snap_bulge_proportion);
|
||||
else if (connector_attributes.style == CutConnectorStyle::Prism)
|
||||
connector_mesh = its_make_cylinder(1.0, 1.0, (2 * PI / sectorCount));
|
||||
|
@ -67,7 +67,7 @@ static const std::map<const wchar_t, std::string> font_icons = {
|
||||
{ImGui::InfoMarkerSmall , "notification_info" },
|
||||
{ImGui::PlugMarker , "plug" },
|
||||
{ImGui::DowelMarker , "dowel" },
|
||||
{ImGui::RivetMarker , "rivet" },
|
||||
{ImGui::SnapMarker , "snap" },
|
||||
};
|
||||
|
||||
static const std::map<const wchar_t, std::string> font_icons_large = {
|
||||
|
Loading…
x
Reference in New Issue
Block a user