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

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

Inheritance diagram for Slic3r::GUI::OtherLayersSeqPanel:
Collaboration diagram for Slic3r::GUI::OtherLayersSeqPanel:

Public Member Functions

 OtherLayersSeqPanel (wxWindow *parent)
void sync_layers_print_seq (int selection, const std::vector< LayerSeqInfo > &seq)
int get_layers_print_seq_choice ()
std::vector< LayerSeqInfo > get_layers_print_seq_infos ()
void enable_seq_choice (bool enable)

Protected Member Functions

void append_layer (const LayerSeqInfo *layer_info=nullptr)
void popup_layer ()
void clear_all_layers ()

Private Attributes

ScalableBitmap m_bmp_delete
ScalableBitmap m_bmp_add
ComboBox * m_other_layer_print_seq_choice { nullptr }
wxPanel * m_layer_input_panel { nullptr }
std::vector< wxBoxSizer * > m_layer_input_sizer_list
std::vector< LayerNumberTextInput * > m_begin_layer_input_list
std::vector< LayerNumberTextInput * > m_end_layer_input_list
std::vector< DragCanvas * > m_drag_canvas_list
std::vector< LayerSeqInfo > m_layer_seq_infos

Detailed Description

Constructor & Destructor Documentation

◆ OtherLayersSeqPanel()

Slic3r::GUI::OtherLayersSeqPanel::OtherLayersSeqPanel ( wxWindow * parent)
202 :wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize)
203{
204 m_bmp_delete = ScalableBitmap(this, "delete_filament");
205 m_bmp_add = ScalableBitmap(this, "add_filament");
206
207 SetBackgroundColour(*wxWHITE);
208
209 wxBoxSizer* top_sizer = new wxBoxSizer(wxVERTICAL);
210
211 wxBoxSizer* title_sizer = new wxBoxSizer(wxHORIZONTAL);
212 m_other_layer_print_seq_choice = new ComboBox(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(FromDIP(240), -1), 0, NULL, wxCB_READONLY);
213 m_other_layer_print_seq_choice->Append(_L("Auto"));
214 m_other_layer_print_seq_choice->Append(_L("Customize"));
215 m_other_layer_print_seq_choice->SetSelection(0);
216 wxStaticText* other_layer_txt = new wxStaticText(this, wxID_ANY, _L("Other layer filament sequence"));
217 other_layer_txt->SetFont(Label::Body_14);
218 title_sizer->Add(other_layer_txt, 0, wxALIGN_CENTER | wxALIGN_LEFT, 0);
219 title_sizer->AddStretchSpacer();
220 title_sizer->Add(m_other_layer_print_seq_choice, 0, wxALIGN_CENTER | wxALIGN_RIGHT, 0);
221
222 wxBoxSizer* buttons_sizer = new wxBoxSizer(wxHORIZONTAL);
223 ScalableButton* add_layers_btn = new ScalableButton(this, wxID_ANY, m_bmp_add);
224 add_layers_btn->SetBackgroundColour(GetBackgroundColour());
225 ScalableButton* delete_layers_btn = new ScalableButton(this, wxID_ANY, m_bmp_delete);
226 delete_layers_btn->SetBackgroundColour(GetBackgroundColour());
227 buttons_sizer->Add(add_layers_btn, 0, wxLEFT | wxRIGHT | wxALIGN_CENTER, FromDIP(5));
228 buttons_sizer->Add(delete_layers_btn, 0, wxLEFT | wxRIGHT | wxALIGN_CENTER, FromDIP(5));
229 buttons_sizer->Show(false);
230
231 m_layer_input_panel = new wxPanel(this);
232 wxBoxSizer* layer_panel_sizer = new wxBoxSizer(wxVERTICAL);
233 m_layer_input_panel->SetSizer(layer_panel_sizer);
234 m_layer_input_panel->Hide();
235 append_layer();
236
237 top_sizer->Add(title_sizer, 0, wxEXPAND, 0);
238 top_sizer->Add(buttons_sizer, 0, wxALIGN_CENTER, 0);
239 top_sizer->Add(m_layer_input_panel, 0, wxEXPAND, 0);
240
241 SetSizer(top_sizer);
242 Layout();
243 top_sizer->Fit(this);
244
245
246 m_other_layer_print_seq_choice->Bind(wxEVT_COMBOBOX, [this, buttons_sizer](auto& e) {
247 if (e.GetSelection() == 0) {
248 m_layer_input_panel->Show(false);
249 buttons_sizer->Show(false);
250 }
251 else if (e.GetSelection() == 1) {
252 m_layer_input_panel->Show(true);
253 buttons_sizer->Show(true);
254 }
255 m_parent->Layout();
256 m_parent->Fit();
257 });
258 add_layers_btn->Bind(wxEVT_BUTTON, [this](wxEvent&) {
259 Freeze();
260 append_layer();
261 m_parent->Layout();
262 m_parent->Fit();
263 Thaw();
264 });
265 delete_layers_btn->Bind(wxEVT_BUTTON, [this](wxEvent&) {
266 popup_layer();
267 m_parent->Layout();
268 m_parent->Fit();
269 });
270 Bind(EVT_NEED_RESORT_LAYERS, [this](auto& evt) {
271 std::vector<LayerSeqInfo> result;
272 for (int i = 0; i < m_layer_input_sizer_list.size(); i++) {
273 int begin_layer_number = m_begin_layer_input_list[i]->get_layer_number();
274 int end_layer_number = m_end_layer_input_list[i]->get_layer_number();
275 result.push_back({ begin_layer_number, end_layer_number, m_drag_canvas_list[i]->get_shape_list_order() });
276 }
277 if (!std::is_sorted(result.begin(), result.end())) {
278 std::sort(result.begin(), result.end());
279 sync_layers_print_seq(1, result);
280 }
281 result.swap(m_layer_seq_infos);
282 });
283 Bind(EVT_SET_BED_TYPE_CONFIRM, [this](auto& evt) {
284 std::vector<LayerSeqInfo> result;
285 for (int i = 0; i < m_layer_input_sizer_list.size(); i++) {
286 int begin_layer_number = m_begin_layer_input_list[i]->get_layer_number();
287 int end_layer_number = m_end_layer_input_list[i]->get_layer_number();
288
289 if (!m_begin_layer_input_list[i]->is_layer_number_valid() || !m_end_layer_input_list[i]->is_layer_number_valid()) {
290 MessageDialog msg_dlg(nullptr, _L("Please input layer value (>= 2)."), wxEmptyString, wxICON_WARNING | wxOK);
291 msg_dlg.ShowModal();
292 evt.SetString("Invalid");
293 return;
294 }
295
296 result.push_back({ begin_layer_number, end_layer_number, m_drag_canvas_list[i]->get_shape_list_order() });
297 }
298 result.swap(m_layer_seq_infos);
299 });
300}
#define _L(s)
Definition OBJ.cpp:34
class WXDLLIMPEXP_FWD_CORE wxStaticText
Definition ProgressDialog.hpp:30
static wxFont Body_14
Definition Label.hpp:53
void popup_layer()
Definition PlateSettingsDialog.cpp:349
void sync_layers_print_seq(int selection, const std::vector< LayerSeqInfo > &seq)
Definition PlateSettingsDialog.cpp:371
wxPanel * m_layer_input_panel
Definition PlateSettingsDialog.hpp:91
std::vector< LayerNumberTextInput * > m_begin_layer_input_list
Definition PlateSettingsDialog.hpp:93
std::vector< DragCanvas * > m_drag_canvas_list
Definition PlateSettingsDialog.hpp:95
std::vector< LayerNumberTextInput * > m_end_layer_input_list
Definition PlateSettingsDialog.hpp:94
ScalableBitmap m_bmp_delete
Definition PlateSettingsDialog.hpp:88
ScalableBitmap m_bmp_add
Definition PlateSettingsDialog.hpp:89
void append_layer(const LayerSeqInfo *layer_info=nullptr)
Definition PlateSettingsDialog.cpp:302
std::vector< LayerSeqInfo > m_layer_seq_infos
Definition PlateSettingsDialog.hpp:96
std::vector< wxBoxSizer * > m_layer_input_sizer_list
Definition PlateSettingsDialog.hpp:92
ComboBox * m_other_layer_print_seq_choice
Definition PlateSettingsDialog.hpp:90

References _L, append_layer(), Label::Body_14, m_begin_layer_input_list, m_bmp_add, m_bmp_delete, m_drag_canvas_list, m_end_layer_input_list, m_layer_input_panel, m_layer_input_sizer_list, m_layer_seq_infos, m_other_layer_print_seq_choice, popup_layer(), Slic3r::GUI::DPIAware< P >::ShowModal(), sync_layers_print_seq(), and wxStaticText.

Here is the call graph for this function:

Member Function Documentation

◆ append_layer()

void Slic3r::GUI::OtherLayersSeqPanel::append_layer ( const LayerSeqInfo * layer_info = nullptr)
protected
303{
304 wxBoxSizer* layer_panel_sizer = static_cast<wxBoxSizer*>(m_layer_input_panel->GetSizer());
305
306 wxStaticText* choose_layer_head_txt = new wxStaticText(m_layer_input_panel, wxID_ANY, _L("Layer"));
307 choose_layer_head_txt->SetFont(Label::Body_14);
308
309 LayerNumberTextInput* begin_layer_input = new LayerNumberTextInput(m_layer_input_panel, -1, wxSize(FromDIP(100), -1), LayerNumberTextInput::Type::Begin, LayerNumberTextInput::ValueType::Custom);
310
311 wxStaticText* choose_layer_to_txt = new wxStaticText(m_layer_input_panel, wxID_ANY, _L("to"));
312 choose_layer_to_txt->SetFont(Label::Body_14);
313
314 LayerNumberTextInput* end_layer_input = new LayerNumberTextInput(m_layer_input_panel, -1, wxSize(FromDIP(100), -1), LayerNumberTextInput::Type::End, LayerNumberTextInput::ValueType::End);
315
316 begin_layer_input->link(end_layer_input);
317 if (m_begin_layer_input_list.size() == 0) {
318 begin_layer_input->set_layer_number(MIN_LAYER_VALUE);
319 end_layer_input->set_layer_number(MAX_LAYER_VALUE);
320 }
321
322 const std::vector<std::string> extruder_colours = wxGetApp().plater()->get_extruder_colors_from_plater_config();
323 std::vector<int> order(extruder_colours.size());
324 for (int i = 0; i < order.size(); i++) {
325 order[i] = i + 1;
326 }
327 auto drag_canvas = new DragCanvas(m_layer_input_panel, extruder_colours, order);
328
329 if (layer_info) {
330 begin_layer_input->set_layer_number(std::max(MIN_LAYER_VALUE, layer_info->begin_layer_number));
331 end_layer_input->set_layer_number(std::min(MAX_LAYER_VALUE, layer_info->end_layer_number));
332 drag_canvas->set_shape_list(extruder_colours, layer_info->print_sequence);
333 }
334
335 wxBoxSizer* single_layer_input_sizer = new wxBoxSizer(wxHORIZONTAL);
336 single_layer_input_sizer->Add(choose_layer_head_txt, 0, wxRIGHT | wxALIGN_CENTER, FromDIP(5));
337 single_layer_input_sizer->Add(begin_layer_input, 0, wxLEFT | wxRIGHT | wxALIGN_CENTER, FromDIP(5));
338 single_layer_input_sizer->Add(choose_layer_to_txt, 0, wxLEFT | wxRIGHT | wxALIGN_CENTER, 0);
339 single_layer_input_sizer->Add(end_layer_input, 0, wxLEFT | wxRIGHT | wxALIGN_CENTER, FromDIP(5));
340 single_layer_input_sizer->AddStretchSpacer();
341 single_layer_input_sizer->Add(drag_canvas, 0, wxLEFT | wxALIGN_CENTER, FromDIP(5));
342 layer_panel_sizer->Add(single_layer_input_sizer, 0, wxEXPAND | wxBOTTOM, FromDIP(10));
343 m_layer_input_sizer_list.push_back(single_layer_input_sizer);
344 m_begin_layer_input_list.push_back(begin_layer_input);
345 m_end_layer_input_list.push_back(end_layer_input);
346 m_drag_canvas_list.push_back(drag_canvas);
347}
@ End
Definition PlateSettingsDialog.hpp:46
@ Custom
Definition PlateSettingsDialog.hpp:45
@ Begin
Definition PlateSettingsDialog.hpp:41
@ End
Definition PlateSettingsDialog.hpp:42
static constexpr int MAX_LAYER_VALUE
Definition PlateSettingsDialog.cpp:33
static constexpr int MIN_LAYER_VALUE
Definition PlateSettingsDialog.cpp:32

References _L, Slic3r::GUI::LayerNumberTextInput::Begin, Slic3r::GUI::LayerSeqInfo::begin_layer_number, Label::Body_14, Slic3r::GUI::LayerNumberTextInput::Custom, Slic3r::GUI::LayerNumberTextInput::End, Slic3r::GUI::LayerSeqInfo::end_layer_number, Slic3r::GUI::LayerNumberTextInput::link(), m_begin_layer_input_list, m_drag_canvas_list, m_end_layer_input_list, m_layer_input_panel, m_layer_input_sizer_list, Slic3r::GUI::MAX_LAYER_VALUE, Slic3r::GUI::MIN_LAYER_VALUE, Slic3r::GUI::LayerSeqInfo::print_sequence, Slic3r::GUI::LayerNumberTextInput::set_layer_number(), and wxStaticText.

Referenced by OtherLayersSeqPanel(), and sync_layers_print_seq().

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

◆ clear_all_layers()

void Slic3r::GUI::OtherLayersSeqPanel::clear_all_layers ( )
protected
361{
362 for (auto sizer : m_layer_input_sizer_list) {
363 sizer->Clear(true);
364 }
368 m_drag_canvas_list.clear();
369}

References m_begin_layer_input_list, m_drag_canvas_list, m_end_layer_input_list, and m_layer_input_sizer_list.

Referenced by sync_layers_print_seq().

Here is the caller graph for this function:

◆ enable_seq_choice()

void Slic3r::GUI::OtherLayersSeqPanel::enable_seq_choice ( bool enable)
inline

◆ get_layers_print_seq_choice()

int Slic3r::GUI::OtherLayersSeqPanel::get_layers_print_seq_choice ( )
inline
75{ return m_other_layer_print_seq_choice->GetSelection(); };

References m_other_layer_print_seq_choice.

◆ get_layers_print_seq_infos()

std::vector< LayerSeqInfo > Slic3r::GUI::OtherLayersSeqPanel::get_layers_print_seq_infos ( )
inline
77{ return m_layer_seq_infos; }

References m_layer_seq_infos.

◆ popup_layer()

void Slic3r::GUI::OtherLayersSeqPanel::popup_layer ( )
protected
350{
351 if (m_layer_input_sizer_list.size() > 1) {
352 m_layer_input_sizer_list.back()->Clear(true);
353 m_layer_input_sizer_list.pop_back();
354 m_begin_layer_input_list.pop_back();
355 m_end_layer_input_list.pop_back();
356 m_drag_canvas_list.pop_back();
357 }
358}

References m_begin_layer_input_list, m_drag_canvas_list, m_end_layer_input_list, and m_layer_input_sizer_list.

Referenced by OtherLayersSeqPanel().

Here is the caller graph for this function:

◆ sync_layers_print_seq()

void Slic3r::GUI::OtherLayersSeqPanel::sync_layers_print_seq ( int selection,
const std::vector< LayerSeqInfo > & seq )
372{
373 if (m_other_layer_print_seq_choice != nullptr) {
374 if (selection == 1) {
376 Freeze();
377 for (int i = 0; i < seq.size(); i++) {
378 append_layer(&seq[i]);
379 }
380 Thaw();
381 }
382 m_other_layer_print_seq_choice->SetSelection(selection);
383
384 wxCommandEvent event(wxEVT_COMBOBOX);
385 event.SetInt(selection);
386 event.SetEventObject(m_other_layer_print_seq_choice);
387 wxPostEvent(m_other_layer_print_seq_choice, event);
388 }
389}
void clear_all_layers()
Definition PlateSettingsDialog.cpp:360

References append_layer(), clear_all_layers(), and m_other_layer_print_seq_choice.

Referenced by OtherLayersSeqPanel().

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

Member Data Documentation

◆ m_begin_layer_input_list

std::vector<LayerNumberTextInput*> Slic3r::GUI::OtherLayersSeqPanel::m_begin_layer_input_list
private

◆ m_bmp_add

ScalableBitmap Slic3r::GUI::OtherLayersSeqPanel::m_bmp_add
private

Referenced by OtherLayersSeqPanel().

◆ m_bmp_delete

ScalableBitmap Slic3r::GUI::OtherLayersSeqPanel::m_bmp_delete
private

Referenced by OtherLayersSeqPanel().

◆ m_drag_canvas_list

std::vector<DragCanvas*> Slic3r::GUI::OtherLayersSeqPanel::m_drag_canvas_list
private

◆ m_end_layer_input_list

std::vector<LayerNumberTextInput*> Slic3r::GUI::OtherLayersSeqPanel::m_end_layer_input_list
private

◆ m_layer_input_panel

wxPanel* Slic3r::GUI::OtherLayersSeqPanel::m_layer_input_panel { nullptr }
private
91{ nullptr };

Referenced by OtherLayersSeqPanel(), and append_layer().

◆ m_layer_input_sizer_list

std::vector<wxBoxSizer*> Slic3r::GUI::OtherLayersSeqPanel::m_layer_input_sizer_list
private

◆ m_layer_seq_infos

std::vector<LayerSeqInfo> Slic3r::GUI::OtherLayersSeqPanel::m_layer_seq_infos
private

◆ m_other_layer_print_seq_choice

ComboBox* Slic3r::GUI::OtherLayersSeqPanel::m_other_layer_print_seq_choice { nullptr }
private

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