mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-14 03:06:08 +08:00
Merge branch 'cppgui'
This commit is contained in:
commit
16ec67322a
@ -305,7 +305,7 @@ set(LIBSLIC3R_DEPENDS
|
||||
${Boost_LIBRARIES}
|
||||
)
|
||||
|
||||
IF(wxWidgets_FOUND)
|
||||
IF(wxWidgets_FOUND AND Enable_GUI)
|
||||
MESSAGE("wx found!")
|
||||
INCLUDE("${wxWidgets_USE_FILE}")
|
||||
|
||||
@ -379,11 +379,13 @@ IF(wxWidgets_FOUND)
|
||||
add_test(NAME TestGUI COMMAND gui_test)
|
||||
target_link_libraries(gui_test PUBLIC libslic3r slic3r_gui Catch ${wxWidgets_LIBRARIES} ${LIBSLIC3R_DEPENDS} ${OPENGL_LIBRARIES})
|
||||
endif()
|
||||
ELSE(wxWidgets_FOUND)
|
||||
ELSE(wxWidgets_FOUND AND Enable_GUI)
|
||||
# For convenience. When we cannot continue, inform the user
|
||||
MESSAGE("wx not found!")
|
||||
if (Enable_GUI)
|
||||
MESSAGE("wx not found!")
|
||||
endif (Enable_GUI)
|
||||
#skip gui when no wx included
|
||||
ENDIF(wxWidgets_FOUND)
|
||||
ENDIF(wxWidgets_FOUND AND Enable_GUI)
|
||||
|
||||
target_link_libraries (slic3r libslic3r ${LIBSLIC3R_DEPENDS})
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include "IO.hpp"
|
||||
#include "Model.hpp"
|
||||
#include "SLAPrint.hpp"
|
||||
#include "Print.hpp"
|
||||
#include "TriangleMesh.hpp"
|
||||
#include "libslic3r.h"
|
||||
#include <cstdio>
|
||||
@ -44,10 +45,16 @@ main(int argc, char **argv)
|
||||
DynamicPrintConfig print_config;
|
||||
|
||||
#ifdef USE_WX
|
||||
GUI::App *gui = new GUI::App();
|
||||
|
||||
GUI::App::SetInstance(gui);
|
||||
wxEntry(argc, argv);
|
||||
if (cli_config.gui) {
|
||||
GUI::App *gui = new GUI::App();
|
||||
|
||||
GUI::App::SetInstance(gui);
|
||||
wxEntry(argc, argv);
|
||||
}
|
||||
#else
|
||||
if (cli_config.gui) {
|
||||
std::cout << "GUI support has not been built." << "\n";
|
||||
}
|
||||
#endif
|
||||
// load config files supplied via --load
|
||||
for (const std::string &file : cli_config.load.values) {
|
||||
@ -113,6 +120,14 @@ main(int argc, char **argv)
|
||||
// TODO: handle --merge
|
||||
models.push_back(model);
|
||||
}
|
||||
if (cli_config.help) {
|
||||
std::cout << "Slic3r " << SLIC3R_VERSION << " is a STL-to-GCODE translator for RepRap 3D printers" << "\n"
|
||||
<< "written by Alessandro Ranellucci <aar@cpan.org> - http://slic3r.org/ - https://github.com/slic3r/Slic3r" << "\n"
|
||||
<< "Git Version " << BUILD_COMMIT << "\n\n"
|
||||
<< "Usage: slic3r.pl [ OPTIONS ] [ file.stl ] [ file2.stl ] ..." << "\n";
|
||||
print_cli_options(boost::nowide::cout);
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (Model &model : models) {
|
||||
if (cli_config.info) {
|
||||
@ -199,6 +214,23 @@ main(int argc, char **argv)
|
||||
IO::STL::write(*m, ss.str());
|
||||
delete m;
|
||||
}
|
||||
} else if (cli_config.slice) {
|
||||
std::string outfile = cli_config.output.value;
|
||||
Print print;
|
||||
|
||||
model.arrange_objects(print.config.min_object_distance());
|
||||
model.center_instances_around_point(cli_config.center);
|
||||
if (outfile.empty()) outfile = model.objects.front()->input_file + ".gcode";
|
||||
print.apply_config(print_config);
|
||||
|
||||
for (auto* mo : model.objects) {
|
||||
print.auto_assign_extruders(mo);
|
||||
print.add_model_object(mo);
|
||||
}
|
||||
print.validate();
|
||||
|
||||
print.export_gcode(outfile);
|
||||
|
||||
} else {
|
||||
boost::nowide::cerr << "error: command not supported" << std::endl;
|
||||
return 1;
|
||||
|
@ -376,7 +376,7 @@ SCENARIO( "TriangleMeshSlicer: Cut behavior.") {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef TEST_PERFORMANCE
|
||||
TEST_CASE("Regression test for issue #4486 - files take forever to slice") {
|
||||
TriangleMesh mesh;
|
||||
auto config {Slic3r::Config::new_from_defaults()};
|
||||
@ -401,6 +401,7 @@ TEST_CASE("Regression test for issue #4486 - files take forever to slice") {
|
||||
REQUIRE(timedout == false);
|
||||
|
||||
}
|
||||
#endif // TEST_PERFORMANCE
|
||||
|
||||
#ifdef BUILD_PROFILE
|
||||
TEST_CASE("Profile test for issue #4486 - files take forever to slice") {
|
||||
|
@ -717,6 +717,14 @@ Print::export_gcode(std::ostream& output, bool quiet)
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
Print::export_gcode(const std::string& outfile, bool quiet)
|
||||
{
|
||||
std::ofstream outstream(outfile);
|
||||
this->export_gcode(outstream);
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
Print::apply_config(config_ptr config) {
|
||||
// dereference the stored pointer and pass the resulting data to apply_config()
|
||||
|
@ -1605,6 +1605,7 @@ PrintConfigDef::PrintConfigDef()
|
||||
def->label = "Threads";
|
||||
def->tooltip = "Threads are used to parallelize long-running tasks. Optimal threads number is slightly above the number of available cores/processors.";
|
||||
def->readonly = true;
|
||||
def->cli = "threads=i";
|
||||
def->min = 1;
|
||||
{
|
||||
unsigned int threads = boost::thread::hardware_concurrency();
|
||||
@ -1942,6 +1943,24 @@ CLIConfigDef::CLIConfigDef()
|
||||
def->tooltip = "Slice the model and export slices as 3MF.";
|
||||
def->cli = "export-3mf";
|
||||
def->default_value = new ConfigOptionBool(false);
|
||||
|
||||
def = this->add("slice", coBool);
|
||||
def->label = "Slice";
|
||||
def->tooltip = "Slice the model and export gcode.";
|
||||
def->cli = "slice";
|
||||
def->default_value = new ConfigOptionBool(false);
|
||||
|
||||
def = this->add("help", coBool);
|
||||
def->label = "Help";
|
||||
def->tooltip = "Show this help.";
|
||||
def->cli = "help";
|
||||
def->default_value = new ConfigOptionBool(false);
|
||||
|
||||
def = this->add("gui", coBool);
|
||||
def->label = "Use GUI";
|
||||
def->tooltip = "Start the Slic3r GUI.";
|
||||
def->cli = "gui";
|
||||
def->default_value = new ConfigOptionBool(false);
|
||||
|
||||
def = this->add("info", coBool);
|
||||
def->label = "Output Model Info";
|
||||
@ -1996,8 +2015,27 @@ CLIConfigDef::CLIConfigDef()
|
||||
def->tooltip = "Scale to fit the given volume.";
|
||||
def->cli = "scale-to-fit";
|
||||
def->default_value = new ConfigOptionPoint3(Pointf3(0,0,0));
|
||||
|
||||
def = this->add("center", coPoint3);
|
||||
def->label = "Center";
|
||||
def->tooltip = "Center the print around the given center (default: 100, 100).";
|
||||
def->cli = "center";
|
||||
def->default_value = new ConfigOptionPoint(Pointf(100,100));
|
||||
}
|
||||
|
||||
const CLIConfigDef cli_config_def;
|
||||
|
||||
std::ostream&
|
||||
print_cli_options(std::ostream& out) {
|
||||
for (const auto& opt : print_config_def.options) {
|
||||
out << "\t" << std::left << std::setw(40) << std::string("--") + opt.second.cli;
|
||||
out << "\t" << opt.second.tooltip << "\n";
|
||||
if (opt.second.default_value != nullptr)
|
||||
out << "\t" << std::setw(40) << " " << "\t" << " (default: " << opt.second.default_value->serialize() << ")";
|
||||
out << "\n";
|
||||
}
|
||||
std::cerr << std::endl;
|
||||
return out;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -659,7 +659,9 @@ class CLIConfig
|
||||
ConfigOptionBool export_pov;
|
||||
ConfigOptionBool export_svg;
|
||||
ConfigOptionBool export_3mf;
|
||||
ConfigOptionBool gui;
|
||||
ConfigOptionBool info;
|
||||
ConfigOptionBool help;
|
||||
ConfigOptionStrings load;
|
||||
ConfigOptionString output;
|
||||
ConfigOptionFloat rotate;
|
||||
@ -668,6 +670,8 @@ class CLIConfig
|
||||
ConfigOptionString save;
|
||||
ConfigOptionFloat scale;
|
||||
ConfigOptionPoint3 scale_to_fit;
|
||||
ConfigOptionPoint center;
|
||||
ConfigOptionBool slice;
|
||||
ConfigOptionBool threads;
|
||||
|
||||
CLIConfig() : ConfigBase(), StaticConfig() {
|
||||
@ -684,6 +688,8 @@ class CLIConfig
|
||||
OPT_PTR(export_pov);
|
||||
OPT_PTR(export_svg);
|
||||
OPT_PTR(export_3mf);
|
||||
OPT_PTR(gui);
|
||||
OPT_PTR(help);
|
||||
OPT_PTR(info);
|
||||
OPT_PTR(load);
|
||||
OPT_PTR(output);
|
||||
@ -693,12 +699,15 @@ class CLIConfig
|
||||
OPT_PTR(save);
|
||||
OPT_PTR(scale);
|
||||
OPT_PTR(scale_to_fit);
|
||||
OPT_PTR(slice);
|
||||
OPT_PTR(threads);
|
||||
|
||||
return NULL;
|
||||
};
|
||||
};
|
||||
|
||||
/// Iterate through all of the options and write them to a stream.
|
||||
std::ostream& print_cli_options(std::ostream& out);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user