예제 #1
0
void ModelViewController::WriteGCode (string filename)
{
  Fl_Text_Buffer* buffer = gui->GCodeResult->buffer();
  int result = buffer->savefile (filename.c_str());

  switch (result)
    {
    case 0: // Succes
      break;
    case 1: // Open for write failed
      fl_alert ("Error saving GCode file, error creating file.");
      break;
    case 2: // Partially saved file
      fl_alert ("Error saving GCode file, while writing file, is the disk full?.");
      break;
    }
}
예제 #2
0
int main(int argc, char *argv[])
{
	// example: Repsnapper.exe --no-gui -i Input.stl -o Output.gcode -s Settings.xml
	RepSnapper::CommandLineOptions options;
	for (int i = 1; i < argc; i++)
	{
		if (strcmp(argv[i], "--no-gui") == 0)
		{
			options.use_gui = false;
		}
		else if (strcmp(argv[i], "-i") == 0 && i + 1 < argc)
		{
			options.stl_input_path = argv[i+1];
			i++;
		}
		else if (strcmp(argv[i], "-o") == 0 && i + 1 < argc)
		{
			options.gcode_output_path = argv[i+1];
			i++;
		}
		else if (strcmp(argv[i], "-s") == 0 && i + 1 < argc)
		{
			options.settings_path = argv[i+1];
			i++;
		}
	}
	
	gui = new GUI();
	MVC = gui->MVC;
	Fl::visual(FL_DOUBLE|FL_INDEX);

	char WindowTitle[100] = "GCodeView";
	char* W = &WindowTitle[0];
	MVC->gui = gui;
	MVC->serial.setGUI(gui);
	MVC->ProcessControl.gui = gui;
	gui->show(1,&W);

	if (!options.use_gui)
	{
		if (options.stl_input_path.size() > 0)
		{
			MVC->ReadStl(options.stl_input_path);

			if (options.settings_path.size() > 0)
			{
				MVC->ProcessControl.LoadXML(options.settings_path);
				MVC->CopySettingsToGUI();
			}

			MVC->ConvertToGCode();

			if (options.gcode_output_path.size() > 0)
			{
				Fl_Text_Buffer *buffer = gui->GCodeResult->buffer();

				return buffer->savefile(options.gcode_output_path.c_str());
			}
		}
		return 0;
	}
	
	return Fl::run();
}