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
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 {
2006 font.MakeBold();
2008 }
2009
2013 if (
m_canvas->pane_state().has_layer)
2015 });
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
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);
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.");
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
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
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);
2119
2120
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
2139
2140
2141 m_seam_angle->Bind(wxEVT_SPINCTRL, [
this](wxCommandEvent &) {
2143 if (value !=
int(std::lround(
m_canvas->pane_state().seam_angle_deg)))
2145 });
2146 const auto send_connect = [this]() {
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 &) {
2156 return;
2158 send_connect();
2159 });
2160
2161 m_canvas->set_status_callback([
this](
const wxString &label) {
2166 }
2167 });
2168 m_canvas->set_pane_state_callback([
this](
const UVEditorCanvas::PaneState &state) {
apply_state(state); });
2170
2171
2172
2173 Bind(wxEVT_SHOW, [this](wxShowEvent &e) {
2174 e.Skip();
2175 if (e.IsShown())
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