OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::GUI::UVEditorPanel Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/UVEditorCanvas.hpp>

Inheritance diagram for Slic3r::GUI::UVEditorPanel:
Collaboration diagram for Slic3r::GUI::UVEditorPanel:

Public Member Functions

 UVEditorPanel (wxWindow *parent)
UVEditorCanvas * canvas ()

Private Member Functions

void on_tool (wxCommandEvent &evt)
void apply_state (const UVEditorCanvas::PaneState &state)
void refresh_selection_tools ()

Private Attributes

UVEditorCanvas * m_canvas = nullptr
UVToolButton * m_thumb = nullptr
wxStaticText * m_layer_name = nullptr
wxStaticText * m_tile = nullptr
UVToolButton * m_background [3] {}
UVToolButton * m_unwrap = nullptr
::SpinInput * m_seam_angle = nullptr
::CheckBox * m_connect = nullptr
UVToolButton * m_select [3] {}
UVToolButton * m_mark_seams = nullptr
UVToolButton * m_seam_path = nullptr
UVToolButton * m_clear_seams = nullptr
UVToolButton * m_avg_scale = nullptr
UVToolButton * m_cut = nullptr
UVToolButton * m_join = nullptr
UVToolButton * m_unjoin = nullptr
UVToolButton * m_clear_edits = nullptr
UVToolButton * m_snap = nullptr
UVToolButton * m_frame = nullptr
wxStaticText * m_status = nullptr
wxStaticText * m_stats = nullptr

Detailed Description

Constructor & Destructor Documentation

◆ UVEditorPanel()

Slic3r::GUI::UVEditorPanel::UVEditorPanel ( wxWindow * parent)
explicit
1979 : wxPanel(parent, wxID_ANY)
1980{
1981 const PaneColors c = PaneColors::current();
1982 const int gap = FromDIP(6);
1983 const int pad = FromDIP(8);
1984 SetBackgroundColour(c.bg);
1985
1986 const auto rule = [&](const wxSize &size) {
1987 auto *w = new wxWindow(this, wxID_ANY, wxDefaultPosition, size);
1988 w->SetBackgroundColour(c.rule);
1989 w->SetMinSize(size);
1990 return w;
1991 };
1992 const auto text = [&](const wxString &label, const wxColour &colour, long style = 0) {
1993 auto *t = new wxStaticText(this, wxID_ANY, label, wxDefaultPosition, wxDefaultSize, style);
1994 t->SetForegroundColour(colour);
1995 t->SetBackgroundColour(c.bg);
1996 return t;
1997 };
1998
1999 // ---- header: the layer being edited, the background under the islands, and Unwrap ----
2000 auto *header = new wxBoxSizer(wxHORIZONTAL);
2001 m_thumb = new UVToolButton(this, ID_UV_PICK_TEXTURE, std::string(), wxEmptyString,
2002 _L("Change texture - choose another one from the texture library"), false, false, 26);
2003 m_layer_name = text(wxEmptyString, c.ink, wxST_ELLIPSIZE_END);
2004 {
2005 wxFont font = m_layer_name->GetFont();
2006 font.MakeBold();
2007 m_layer_name->SetFont(font);
2008 }
2009 // The name opens the library too, like the texture's name in the layer card.
2010 m_layer_name->SetCursor(wxCursor(wxCURSOR_HAND));
2011 m_layer_name->SetToolTip(m_thumb->GetToolTipText());
2012 m_layer_name->Bind(wxEVT_LEFT_UP, [this](wxMouseEvent &) {
2013 if (m_canvas->pane_state().has_layer)
2015 });
2016 m_layer_name->SetMinSize(wxSize(FromDIP(30), -1));
2017 m_tile = text(wxEmptyString, c.dim);
2018 m_tile->SetToolTip(_L("The active layer's tile size: how much of the model one repeat of the texture covers. The "
2019 "canvas is measured in tiles, so one grid cell is one repeat. Change it with Tile size in "
2020 "the layer's settings."));
2021 header->Add(m_thumb, 0, wxALIGN_CENTER_VERTICAL);
2022 header->Add(m_layer_name, 1, wxALIGN_CENTER_VERTICAL | wxLEFT, gap);
2023 header->Add(m_tile, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, gap);
2024
2025 const char *const bg_icons[3] = { "texture_displacement_uv_bg_height", "texture_displacement_checker",
2026 "texture_displacement_distortion" };
2027 const wxString bg_tips[3] = { _L("Height map - show the layer's texture under the islands"),
2028 _L("Checker - a test grid; squares stay square where the unwrap does not stretch"),
2029 _L("Distortion - color each island by how much the unwrap stretches it") };
2030 for (int i = 0; i < 3; ++i) {
2031 m_background[i] = new UVToolButton(this, ID_UV_BG_HEIGHT + i, bg_icons[i], wxEmptyString, bg_tips[i], true, false, 22);
2032 header->Add(m_background[i], 0, wxALIGN_CENTER_VERTICAL | wxLEFT, i == 0 ? gap : FromDIP(3));
2033 }
2034 header->Add(rule(wxSize(1, FromDIP(18))), 0, wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT, gap);
2035 m_unwrap = new UVToolButton(this, ID_UV_UNWRAP, "texture_displacement_map_unwrap", _L("Unwrap"), wxEmptyString, false, true, 24);
2036 header->Add(m_unwrap, 0, wxALIGN_CENTER_VERTICAL);
2037
2038 // ---- settings: what the next Unwrap will do ----
2039 auto *settings = new wxBoxSizer(wxHORIZONTAL);
2040 auto *seam_label = text(_L("Seam angle"), c.dim);
2041 m_seam_angle = new ::SpinInput(this, wxEmptyString, wxString::FromUTF8("°"), wxDefaultPosition, wxSize(FromDIP(76), FromDIP(24)), 0,
2042 5, 90, 40);
2043 const wxString seam_tip = _L("Edges sharper than this are cut, and the pieces either side of them are flattened separately. "
2044 "Lower it to cut more: each piece then lies flat with less stretching, at the cost of the "
2045 "texture not running continuously across the cut. Takes effect at the next Unwrap.");
2046 seam_label->SetToolTip(seam_tip);
2047 m_seam_angle->SetToolTip(seam_tip);
2048 m_connect = new ::CheckBox(this);
2049 auto *connect_label = text(_L("Connect islands"), c.ink);
2050 const wxString connect_tip = _L("Lay the unwrap out as a connected net: pieces that share an edge are unfolded next to each "
2051 "other (a cube becomes a joined net rather than six loose squares). They stay separate "
2052 "islands, so you can still move any of them by hand afterwards.");
2053 m_connect->SetToolTip(connect_tip);
2054 connect_label->SetToolTip(connect_tip);
2055 settings->Add(seam_label, 0, wxALIGN_CENTER_VERTICAL);
2056 settings->Add(m_seam_angle, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, gap);
2057 settings->AddStretchSpacer();
2058 settings->Add(m_connect, 0, wxALIGN_CENTER_VERTICAL);
2059 settings->Add(connect_label, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, FromDIP(4));
2060
2061 // ---- tool strip ----
2062 auto *strip = new wxBoxSizer(wxVERTICAL);
2063 const auto tool = [&](int id, const char *icon, const wxString &tip, bool toggle) {
2064 auto *b = new UVToolButton(this, id, icon, wxEmptyString, tip, toggle);
2065 strip->Add(b, 0, wxALIGN_CENTER_HORIZONTAL | wxTOP, FromDIP(4));
2066 return b;
2067 };
2068 // 11 px either side of a group rule (7 below plus the next button's own 4), against 4 px between buttons.
2069 const auto strip_rule = [&]() {
2070 auto *r = rule(wxSize(FromDIP(20), 1));
2071 strip->Add(r, 0, wxALIGN_CENTER_HORIZONTAL | wxTOP, FromDIP(11));
2072 strip->AddSpacer(FromDIP(7));
2073 };
2074 m_select[0] = tool(ID_UV_SELECT_ISLAND, "texture_displacement_uv_select_island",
2075 _L("Island - work on whole islands. Click one to select it, then drag to move it, right-drag to "
2076 "rotate it, or press R to rotate and S to scale with the mouse (click or Enter to confirm, Esc "
2077 "to cancel)."),
2078 true);
2079 m_select[1] = tool(ID_UV_SELECT_VERTEX, "texture_displacement_uv_select_vertex",
2080 _L("Vertex - drag vertices to reshape an island by hand; Shift adds to the selection, Ctrl "
2081 "toggles one in or out of it."),
2082 true);
2083 m_select[2] = tool(ID_UV_SELECT_EDGE, "texture_displacement_uv_select_edge",
2084 _L("Edge - drag edges to reshape an island by hand; Shift adds to the selection, Ctrl toggles "
2085 "one in or out of it."),
2086 true);
2087 strip_rule();
2088 m_mark_seams = tool(ID_UV_MARK_SEAMS, "texture_displacement_uv_seam",
2089 _L("Mark seams - click edges on the model to cut the unwrap along them. The edge under the cursor is "
2090 "highlighted yellow; click to mark it red, click a red edge again to unmark it. Painting is paused "
2091 "while this is on."),
2092 true);
2093 m_seam_path = tool(ID_UV_SEAM_PATH, "texture_displacement_uv_path",
2094 _L("Path - instead of clicking every edge, click a start point and then an end point: the whole "
2095 "shortest path between them is seamed at once. Available while marking seams."),
2096 true);
2097 m_clear_seams = tool(ID_UV_CLEAR_SEAMS, "texture_displacement_cross", _L("Clear seams - remove every seam marked on this layer"), false);
2098 strip_rule();
2099 m_avg_scale = tool(ID_UV_AVG_SCALE, "texture_displacement_uv_avg_scale", _L("Average scale - give every island the same texel density"), false);
2100 m_cut = tool(ID_UV_CUT, "texture_displacement_uv_cut", _L("Cut - split the selected island across its long axis"), false);
2101 m_join = tool(ID_UV_JOIN, "texture_displacement_uv_join", _L("Join - unfold the selected island onto its nearest neighbour along their shared edge"), false);
2102 m_unjoin = tool(ID_UV_UNJOIN, "texture_displacement_uv_unjoin", _L("Unjoin - send the selected island back to its own packed position"), false);
2103 strip->AddStretchSpacer();
2104 m_clear_edits = tool(ID_UV_CLEAR_EDITS, "texture_displacement_uv_clear_edits",
2105 _L("Clear UV edits - discard all manual vertex/edge moves and return the unwrap to its automatic shape"), false);
2106 m_snap = tool(ID_UV_SNAP, "texture_displacement_uv_snap", _L("Snap - stick islands together when dragging one against another"), true);
2107 m_frame = tool(ID_UV_FRAME, "texture_displacement_uv_frame",
2108 _L("Frame all islands, fitting every one of them in view (Home or F).\n"
2109 "Elsewhere on the canvas: scroll to zoom around the cursor, and middle-drag - or drag empty space - "
2110 "to pan."),
2111 false);
2112 strip->AddSpacer(FromDIP(4));
2113
2114 m_canvas = new UVEditorCanvas(this);
2115 auto *body = new wxBoxSizer(wxHORIZONTAL);
2116 body->Add(strip, 0, wxEXPAND | wxLEFT | wxRIGHT, FromDIP(4));
2117 body->Add(rule(wxSize(1, -1)), 0, wxEXPAND);
2118 body->Add(m_canvas, 1, wxEXPAND);
2119
2120 // ---- status line: the current gesture on the left, the unwrap summary on the right ----
2121 m_status = text(wxEmptyString, c.dim, wxST_ELLIPSIZE_END);
2122 m_status->SetToolTip(_L("What is selected, and the exact figures of the move, rotation or scale while you drag one."));
2123 m_status->SetMinSize(wxSize(FromDIP(40), -1));
2124 m_stats = text(wxEmptyString, c.dim);
2125 auto *status = new wxBoxSizer(wxHORIZONTAL);
2126 status->Add(m_status, 1, wxALIGN_CENTER_VERTICAL);
2127 status->Add(m_stats, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, gap);
2128
2129 auto *sizer = new wxBoxSizer(wxVERTICAL);
2130 sizer->Add(header, 0, wxEXPAND | wxLEFT | wxRIGHT | wxTOP, pad);
2131 sizer->Add(settings, 0, wxEXPAND | wxLEFT | wxRIGHT | wxTOP, gap);
2132 sizer->Add(rule(wxSize(-1, 1)), 0, wxEXPAND | wxTOP, gap);
2133 sizer->Add(body, 1, wxEXPAND);
2134 sizer->Add(rule(wxSize(-1, 1)), 0, wxEXPAND);
2135 sizer->Add(status, 0, wxEXPAND | wxLEFT | wxRIGHT | wxTOP | wxBOTTOM, FromDIP(5));
2136 SetSizer(sizer);
2137
2138 Bind(wxEVT_BUTTON, &UVEditorPanel::on_tool, this);
2139 // Both settings compare against the last state the gizmo pushed before sending anything: apply_state()
2140 // writes them back, and without the check that write would bounce straight back to the gizmo as an edit.
2141 m_seam_angle->Bind(wxEVT_SPINCTRL, [this](wxCommandEvent &) {
2142 const int value = m_seam_angle->GetValue();
2143 if (value != int(std::lround(m_canvas->pane_state().seam_angle_deg)))
2144 m_canvas->run_command(UVEditorCanvas::Command::SetSeamAngle, float(value));
2145 });
2146 const auto send_connect = [this]() {
2147 if (m_connect->GetValue() != m_canvas->pane_state().connect_islands)
2148 m_canvas->run_command(UVEditorCanvas::Command::SetConnectIslands, m_connect->GetValue() ? 1.f : 0.f);
2149 };
2150 m_connect->Bind(wxEVT_TOGGLEBUTTON, [send_connect](wxCommandEvent &e) {
2151 send_connect();
2152 e.Skip();
2153 });
2154 connect_label->Bind(wxEVT_LEFT_DOWN, [this, send_connect](wxMouseEvent &) {
2155 if (!m_connect->IsEnabled())
2156 return;
2157 m_connect->SetValue(!m_connect->GetValue());
2158 send_connect();
2159 });
2160
2161 m_canvas->set_status_callback([this](const wxString &label) {
2162 if (m_status != nullptr && m_status->GetLabel() != label) {
2163 m_status->SetLabel(label);
2164 m_status->Refresh();
2165 refresh_selection_tools(); // a selection or mode change is what changes the status line
2166 }
2167 });
2168 m_canvas->set_pane_state_callback([this](const UVEditorCanvas::PaneState &state) { apply_state(state); });
2169 apply_state(m_canvas->pane_state());
2170
2171 // AUI shows and hides the pane through this panel. Rebuild the canvas's GPU objects when it comes back, so
2172 // the texture and islands never depend on surviving the canvas's native window being hidden.
2173 Bind(wxEVT_SHOW, [this](wxShowEvent &e) {
2174 e.Skip();
2175 if (e.IsShown())
2176 m_canvas->invalidate_gl();
2177 });
2178}
#define _L(s)
Definition OBJ.cpp:34
class WXDLLIMPEXP_FWD_CORE wxStaticText
Definition ProgressDialog.hpp:30
#define style
Definition WipeTowerDialog.cpp:101
@ SetSeamAngle
Definition UVEditorCanvas.hpp:115
@ PickTexture
Definition UVEditorCanvas.hpp:116
@ SetConnectIslands
Definition UVEditorCanvas.hpp:115
::SpinInput * m_seam_angle
Definition UVEditorCanvas.hpp:439
UVToolButton * m_cut
Definition UVEditorCanvas.hpp:447
wxStaticText * m_stats
Definition UVEditorCanvas.hpp:455
void on_tool(wxCommandEvent &evt)
Definition UVEditorCanvas.cpp:2275
UVToolButton * m_background[3]
Definition UVEditorCanvas.hpp:436
UVToolButton * m_clear_edits
Definition UVEditorCanvas.hpp:450
wxStaticText * m_tile
Definition UVEditorCanvas.hpp:435
wxStaticText * m_layer_name
Definition UVEditorCanvas.hpp:434
UVToolButton * m_seam_path
Definition UVEditorCanvas.hpp:444
UVToolButton * m_thumb
Definition UVEditorCanvas.hpp:433
UVEditorCanvas * m_canvas
Definition UVEditorCanvas.hpp:431
UVToolButton * m_join
Definition UVEditorCanvas.hpp:448
UVToolButton * m_avg_scale
Definition UVEditorCanvas.hpp:446
wxStaticText * m_status
Definition UVEditorCanvas.hpp:454
UVToolButton * m_frame
Definition UVEditorCanvas.hpp:452
UVToolButton * m_mark_seams
Definition UVEditorCanvas.hpp:443
UVToolButton * m_select[3]
Definition UVEditorCanvas.hpp:442
::CheckBox * m_connect
Definition UVEditorCanvas.hpp:440
UVToolButton * m_unwrap
Definition UVEditorCanvas.hpp:437
UVToolButton * m_unjoin
Definition UVEditorCanvas.hpp:449
UVToolButton * m_clear_seams
Definition UVEditorCanvas.hpp:445
void apply_state(const UVEditorCanvas::PaneState &state)
Definition UVEditorCanvas.cpp:2180
UVToolButton * m_snap
Definition UVEditorCanvas.hpp:451
void refresh_selection_tools()
Definition UVEditorCanvas.cpp:2251
wxMouseEvent
Definition CameraPopup.cpp:47

References _L, apply_state(), m_avg_scale, m_background, m_canvas, m_clear_edits, m_clear_seams, m_connect, m_cut, m_frame, m_join, m_layer_name, m_mark_seams, m_seam_angle, m_seam_path, m_select, m_snap, m_stats, m_status, m_thumb, m_tile, m_unjoin, m_unwrap, on_tool(), Slic3r::GUI::UVEditorCanvas::PickTexture, refresh_selection_tools(), Slic3r::GUI::UVEditorCanvas::SetConnectIslands, Slic3r::GUI::UVEditorCanvas::SetSeamAngle, style, Slic3r::GUI::wxMouseEvent, and wxStaticText.

Here is the call graph for this function:

Member Function Documentation

◆ apply_state()

void Slic3r::GUI::UVEditorPanel::apply_state ( const UVEditorCanvas::PaneState & state)
private
2181{
2182 const wxString name = s.has_layer ? s.layer_name : _L("No layer mapped with Unwrap");
2183 const wxString tile = s.has_layer ? wxString::Format(_L("%.1f mm tile"), s.tile_mm) : wxString();
2184 const bool relayout = m_layer_name->GetLabel() != name || m_tile->GetLabel() != tile;
2185 m_layer_name->SetLabel(name);
2186 m_tile->SetLabel(tile);
2187
2188 if (s.thumbnail_px > 0 && s.thumbnail_rgb.size() == size_t(s.thumbnail_px) * size_t(s.thumbnail_px) * 3) {
2189 // Scaled to device pixels and tagged with the content scale, so HiDPI screens get every pixel of it.
2190 const double scale = GetContentScaleFactor();
2191 const int px = std::max(1, int(std::lround(FromDIP(20) * scale)));
2192 wxImage image(s.thumbnail_px, s.thumbnail_px, false);
2193 std::copy(s.thumbnail_rgb.begin(), s.thumbnail_rgb.end(), image.GetData());
2194 m_thumb->SetBitmap(wxBitmap(image.Scale(px, px, wxIMAGE_QUALITY_HIGH), -1, scale));
2195 } else {
2196 m_thumb->SetBitmap(wxNullBitmap);
2197 }
2198 // Every tool that cannot be used right now is faded with the reason appended to its tooltip, rather than
2199 // being hard-disabled (which would hide the tooltip too - see UVToolButton::SetUnavailable()).
2200 const wxString no_layer = s.has_layer ? wxString() :
2201 _L("The pane follows the active texture layer, and that layer has to be mapped "
2202 "with Unwrap (LSCM). Add a layer and set its Mapping to Unwrap.");
2203 m_thumb->SetUnavailable(no_layer);
2204 m_layer_name->SetToolTip(s.has_layer ? m_thumb->GetToolTipText() : no_layer);
2205
2206 for (int i = 0; i < 3; ++i) {
2207 m_background[i]->SetValue(int(s.background) == i);
2208 m_background[i]->SetUnavailable(no_layer);
2209 }
2210 m_unwrap->SetUnavailable(no_layer);
2211 m_unwrap->SetBadge(s.unwrap_stale);
2212 m_unwrap->SetTip(s.unwrap_stale ?
2213 _L("Out of date - the paint, the seams or the seam angle changed since this unwrap was made. "
2214 "Press to unwrap again.") :
2215 _L("Flatten the painted area into UV islands. It is computed only when you press this, not on "
2216 "every edit - so paint, change the seam angle or mark seams first, then press Unwrap."));
2217
2218 if (m_seam_angle->GetValue() != int(std::lround(s.seam_angle_deg)))
2219 m_seam_angle->SetValue(int(std::lround(s.seam_angle_deg)));
2220 m_seam_angle->Enable(s.has_layer);
2221 m_connect->SetValue(s.connect_islands);
2222 m_connect->Enable(s.has_layer);
2223
2224 m_mark_seams->SetValue(s.mark_seams);
2225 m_mark_seams->SetUnavailable(no_layer);
2226 m_seam_path->SetValue(s.seam_path);
2227 m_seam_path->SetUnavailable(!no_layer.empty() ? no_layer :
2228 s.mark_seams ? wxString() :
2229 _L("Turn Mark seams on first - Path is a quicker way of marking them."));
2230 m_clear_seams->SetUnavailable(!no_layer.empty() ? no_layer :
2231 s.has_seams ? wxString() :
2232 _L("No seams are marked on this layer."));
2233 m_clear_edits->SetUnavailable(!no_layer.empty() ? no_layer :
2234 s.has_uv_edits ? wxString() :
2235 _L("No islands have been reshaped by hand, so there is nothing to "
2236 "discard."));
2237
2238 m_stats->SetLabel(s.unwrapped ? wxString::Format(_L_PLURAL("%d island", "%d islands", s.island_count), s.island_count) + ", " +
2239 wxString::Format(_L_PLURAL("%s face", "%s faces", s.face_count),
2240 wxString(std::to_string(s.face_count))) :
2241 wxString());
2242 m_stats->SetToolTip(s.unwrapped ? _L("How the painted area came out of the unwrap: the number of separate pieces it "
2243 "was cut into (at the seams and at edges sharper than the seam angle), and how "
2244 "many triangles they hold in total.") :
2245 wxString());
2247 if (relayout)
2248 Layout();
2249}
#define _L_PLURAL(s, plural, n)
Definition I18N.hpp:96

References _L, _L_PLURAL, Slic3r::GUI::UVEditorCanvas::PaneState::background, Slic3r::GUI::UVEditorCanvas::PaneState::connect_islands, Slic3r::GUI::UVEditorCanvas::PaneState::face_count, Slic3r::GUI::UVEditorCanvas::PaneState::has_layer, Slic3r::GUI::UVEditorCanvas::PaneState::has_seams, Slic3r::GUI::UVEditorCanvas::PaneState::has_uv_edits, Slic3r::GUI::UVEditorCanvas::PaneState::island_count, Slic3r::GUI::UVEditorCanvas::PaneState::layer_name, m_background, m_clear_edits, m_clear_seams, m_connect, m_layer_name, m_mark_seams, m_seam_angle, m_seam_path, m_stats, m_thumb, m_tile, m_unwrap, Slic3r::GUI::UVEditorCanvas::PaneState::mark_seams, refresh_selection_tools(), scale(), Slic3r::GUI::UVEditorCanvas::PaneState::seam_angle_deg, Slic3r::GUI::UVEditorCanvas::PaneState::seam_path, Slic3r::GUI::UVEditorCanvas::PaneState::thumbnail_px, Slic3r::GUI::UVEditorCanvas::PaneState::thumbnail_rgb, Slic3r::GUI::UVEditorCanvas::PaneState::tile_mm, Slic3r::GUI::UVEditorCanvas::PaneState::unwrap_stale, and Slic3r::GUI::UVEditorCanvas::PaneState::unwrapped.

Referenced by UVEditorPanel().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ canvas()

UVEditorCanvas * Slic3r::GUI::UVEditorPanel::canvas ( )
inline
423{ return m_canvas; }

References m_canvas.

◆ on_tool()

void Slic3r::GUI::UVEditorPanel::on_tool ( wxCommandEvent & evt)
private
2276{
2278 const int id = evt.GetId();
2279 const bool on = evt.GetInt() != 0;
2280 switch (id) {
2281 case ID_UV_FRAME: m_canvas->run_command(Command::FrameAll); break;
2282 case ID_UV_SNAP: m_canvas->run_command(Command::ToggleSnap); break;
2283 case ID_UV_AVG_SCALE: m_canvas->run_command(Command::AverageScale); break;
2284 case ID_UV_CUT: m_canvas->run_command(Command::CutSelectedIsland); break;
2285 case ID_UV_JOIN: m_canvas->run_command(Command::JoinSelected); break;
2286 case ID_UV_UNJOIN: m_canvas->run_command(Command::UnjoinSelected); break;
2287 case ID_UV_UNWRAP: m_canvas->run_command(Command::Unwrap); break;
2288 case ID_UV_MARK_SEAMS: m_canvas->run_command(Command::SetMarkSeams, on ? 1.f : 0.f); break;
2289 case ID_UV_SEAM_PATH: m_canvas->run_command(Command::SetSeamPath, on ? 1.f : 0.f); break;
2290 case ID_UV_CLEAR_SEAMS: m_canvas->run_command(Command::ClearSeams); break;
2291 case ID_UV_CLEAR_EDITS: m_canvas->run_command(Command::ClearUVEdits); break;
2292 case ID_UV_PICK_TEXTURE: m_canvas->run_command(Command::PickTexture); break;
2295 case ID_UV_SELECT_EDGE: m_canvas->run_command(Command::SetSelectMode, float(id - ID_UV_SELECT_ISLAND)); break;
2296 case ID_UV_BG_HEIGHT:
2297 case ID_UV_BG_CHECKER:
2299 // Shown straight away; the gizmo confirms it with its next state push.
2300 for (int i = 0; i < 3; ++i)
2301 m_background[i]->SetValue(i == id - ID_UV_BG_HEIGHT);
2302 m_canvas->run_command(Command::SetBackground, float(id - ID_UV_BG_HEIGHT));
2303 break;
2304 default: evt.Skip(); return;
2305 }
2307}
Command
Definition UVEditorCanvas.hpp:113
@ ID_UV_FRAME
Definition UVEditorCanvas.cpp:1713
@ ID_UV_SELECT_ISLAND
Definition UVEditorCanvas.cpp:1724
@ ID_UV_UNJOIN
Definition UVEditorCanvas.cpp:1718
@ ID_UV_JOIN
Definition UVEditorCanvas.cpp:1717
@ ID_UV_SNAP
Definition UVEditorCanvas.cpp:1714
@ ID_UV_CLEAR_EDITS
Definition UVEditorCanvas.cpp:1723
@ ID_UV_PICK_TEXTURE
Definition UVEditorCanvas.cpp:1730
@ ID_UV_CLEAR_SEAMS
Definition UVEditorCanvas.cpp:1722
@ ID_UV_SELECT_VERTEX
Definition UVEditorCanvas.cpp:1725
@ ID_UV_SEAM_PATH
Definition UVEditorCanvas.cpp:1721
@ ID_UV_CUT
Definition UVEditorCanvas.cpp:1716
@ ID_UV_SELECT_EDGE
Definition UVEditorCanvas.cpp:1726
@ ID_UV_BG_HEIGHT
Definition UVEditorCanvas.cpp:1727
@ ID_UV_UNWRAP
Definition UVEditorCanvas.cpp:1719
@ ID_UV_BG_DISTORTION
Definition UVEditorCanvas.cpp:1729
@ ID_UV_BG_CHECKER
Definition UVEditorCanvas.cpp:1728
@ ID_UV_AVG_SCALE
Definition UVEditorCanvas.cpp:1715
@ ID_UV_MARK_SEAMS
Definition UVEditorCanvas.cpp:1720
@ Command
Definition ActionRegistry.hpp:25

References Slic3r::GUI::Command, m_background, m_canvas, and refresh_selection_tools().

Referenced by UVEditorPanel().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ refresh_selection_tools()

void Slic3r::GUI::UVEditorPanel::refresh_selection_tools ( )
private
2252{
2253 const bool has_islands = m_canvas->has_islands();
2254 const int mode = int(m_canvas->select_mode());
2255 // Faded rather than hard-disabled, so the tooltip still says what is missing (see apply_state()).
2256 const wxString not_unwrapped = has_islands ? wxString() : _L("Press Unwrap first - there are no islands to work on yet.");
2257 for (int i = 0; i < 3; ++i) {
2258 m_select[i]->SetValue(i == mode);
2259 m_select[i]->SetUnavailable(not_unwrapped);
2260 }
2261 const bool island_picked = has_islands && m_canvas->select_mode() == UVEditorCanvas::SelectMode::Island &&
2262 m_canvas->selected_island() >= 0;
2263 const wxString no_island = !not_unwrapped.empty() ? not_unwrapped :
2264 island_picked ? wxString() :
2265 _L("Click an island on the canvas first, in Island mode.");
2266 m_avg_scale->SetUnavailable(not_unwrapped);
2267 m_cut->SetUnavailable(no_island);
2268 m_join->SetUnavailable(no_island);
2269 m_unjoin->SetUnavailable(no_island);
2270 m_snap->SetUnavailable(not_unwrapped);
2271 m_snap->SetValue(m_canvas->snap_enabled());
2272 m_frame->SetUnavailable(not_unwrapped);
2273}
@ Island
Definition UVEditorCanvas.hpp:171

References _L, Slic3r::GUI::UVEditorCanvas::Island, m_avg_scale, m_canvas, m_cut, m_frame, m_join, m_select, m_snap, and m_unjoin.

Referenced by UVEditorPanel(), apply_state(), and on_tool().

Here is the caller graph for this function:

Member Data Documentation

◆ m_avg_scale

UVToolButton* Slic3r::GUI::UVEditorPanel::m_avg_scale = nullptr
private

◆ m_background

UVToolButton* Slic3r::GUI::UVEditorPanel::m_background[3] {}
private
436{};

Referenced by UVEditorPanel(), apply_state(), and on_tool().

◆ m_canvas

UVEditorCanvas* Slic3r::GUI::UVEditorPanel::m_canvas = nullptr
private

◆ m_clear_edits

UVToolButton* Slic3r::GUI::UVEditorPanel::m_clear_edits = nullptr
private

Referenced by UVEditorPanel(), and apply_state().

◆ m_clear_seams

UVToolButton* Slic3r::GUI::UVEditorPanel::m_clear_seams = nullptr
private

Referenced by UVEditorPanel(), and apply_state().

◆ m_connect

::CheckBox* Slic3r::GUI::UVEditorPanel::m_connect = nullptr
private

Referenced by UVEditorPanel(), and apply_state().

◆ m_cut

UVToolButton* Slic3r::GUI::UVEditorPanel::m_cut = nullptr
private

◆ m_frame

UVToolButton* Slic3r::GUI::UVEditorPanel::m_frame = nullptr
private

◆ m_join

UVToolButton* Slic3r::GUI::UVEditorPanel::m_join = nullptr
private

◆ m_layer_name

wxStaticText* Slic3r::GUI::UVEditorPanel::m_layer_name = nullptr
private

Referenced by UVEditorPanel(), and apply_state().

◆ m_mark_seams

UVToolButton* Slic3r::GUI::UVEditorPanel::m_mark_seams = nullptr
private

Referenced by UVEditorPanel(), and apply_state().

◆ m_seam_angle

::SpinInput* Slic3r::GUI::UVEditorPanel::m_seam_angle = nullptr
private

Referenced by UVEditorPanel(), and apply_state().

◆ m_seam_path

UVToolButton* Slic3r::GUI::UVEditorPanel::m_seam_path = nullptr
private

Referenced by UVEditorPanel(), and apply_state().

◆ m_select

UVToolButton* Slic3r::GUI::UVEditorPanel::m_select[3] {}
private
442{};

Referenced by UVEditorPanel(), and refresh_selection_tools().

◆ m_snap

UVToolButton* Slic3r::GUI::UVEditorPanel::m_snap = nullptr
private

◆ m_stats

wxStaticText* Slic3r::GUI::UVEditorPanel::m_stats = nullptr
private

Referenced by UVEditorPanel(), and apply_state().

◆ m_status

wxStaticText* Slic3r::GUI::UVEditorPanel::m_status = nullptr
private

Referenced by UVEditorPanel().

◆ m_thumb

UVToolButton* Slic3r::GUI::UVEditorPanel::m_thumb = nullptr
private

Referenced by UVEditorPanel(), and apply_state().

◆ m_tile

wxStaticText* Slic3r::GUI::UVEditorPanel::m_tile = nullptr
private

Referenced by UVEditorPanel(), and apply_state().

◆ m_unjoin

UVToolButton* Slic3r::GUI::UVEditorPanel::m_unjoin = nullptr
private

◆ m_unwrap

UVToolButton* Slic3r::GUI::UVEditorPanel::m_unwrap = nullptr
private

Referenced by UVEditorPanel(), and apply_state().


The documentation for this class was generated from the following files: