Auto-pick single option. Added support and top/bot infill patterns.

This commit is contained in:
DWW 2021-12-21 19:46:47 +02:00
parent 0d70f0e5a6
commit f03bcf7d89

View File

@ -17,8 +17,10 @@ using namespace std;
int check_folder_structure(void); int check_folder_structure(void);
vector<string> get_folder_entries(const char *folder); vector<string> get_folder_entries(const char *folder);
vector<string> get_choices(void); vector<string> get_file_choices(void);
string pick_option(const string& name, const vector<string>& options); string pick_option(const string& name, const vector<string>& options);
string choose_support();
string choose_pattern(const string& place);
void flush_input(void); void flush_input(void);
void usage(char *name); void usage(char *name);
@ -41,7 +43,7 @@ int main(int argc, char **argv)
} }
// Iterate configurations and build command // Iterate configurations and build command
configurations = get_choices(); configurations = get_file_choices();
command = "slic3r --no-gui"; command = "slic3r --no-gui";
for (it = configurations.begin(); it != configurations.end(); ++it) for (it = configurations.begin(); it != configurations.end(); ++it)
{ {
@ -50,6 +52,20 @@ int main(int argc, char **argv)
command += "\""; command += "\"";
} }
// Support choices
command += choose_support();
// Bottom pattern choices
command += " --bottom-infill-pattern \"";
command += choose_pattern("Bottom Infill");
command += "\"";
// Top pattern choices
command += " --top-infill-pattern \"";
command += choose_pattern("Top Infill");
command += "\"";
// Add filename
command += " \""; command += " \"";
command += argv[1]; command += argv[1];
command += "\""; command += "\"";
@ -125,7 +141,7 @@ vector<string> get_folder_entries(const char *folder)
return result; return result;
} }
vector<string> get_choices(void) vector<string> get_file_choices(void)
{ {
vector<string> result; vector<string> result;
vector<string> options; vector<string> options;
@ -165,8 +181,12 @@ string pick_option(const string& name, const vector<string>& options)
int i; int i;
int error; int error;
printf("Available %s configurations:\n", name.c_str()); if (1 == options.size())
printf("%-2d - Use slic3r defaults\n", 0); {
return options[0];
}
printf("Choose %s configuration:\n", name.c_str());
i = 1; i = 1;
for (it = options.begin(); it != options.end(); ++it) for (it = options.begin(); it != options.end(); ++it)
{ {
@ -184,18 +204,43 @@ redo_choice:
goto redo_choice; goto redo_choice;
} }
if ((i < 0) || (i > options.size())) if ((i <= 0) || (i > options.size()))
{ {
printf("Number out of bounds. Try again.\n"); printf("Number out of bounds. Try again.\n");
goto redo_choice; goto redo_choice;
} }
if (0 == i) return options[i - 1];
}
string choose_support()
{
vector<string> options;
options.push_back("Do not generate support");
options.push_back("Generate support");
if (pick_option("Support", options) == options[1])
{
return "--support-material";
}
else
{ {
return ""; return "";
} }
}
return options[i - 1]; string choose_pattern(const string& place)
{
vector<string> options;
options.push_back("rectilinear");
options.push_back("concentric");
options.push_back("hilbertcurve");
options.push_back("archimedeanchords");
options.push_back("octagramspiral");
return pick_option(place, options);
} }
void flush_input() void flush_input()