void Model::DeleteObjTree(vector<Gtk::TreeModel::Path> &iter) { objtree.DeleteSelected (iter); ClearGCode(); ClearLayers(); ModelChanged(); }
Model::~Model() { ClearLayers(); ClearGCode(); delete m_previewLayer; preview_shapes.clear(); }
void Model::ModelChanged() { if (m_inhibit_modelchange) return; //printer.update_temp_poll_interval(); // necessary? if (!is_printing) { CalcBoundingBoxAndCenter(); Infill::clearPatterns(); if ( layers.size()>0 || m_previewGCode.size()>0 || m_previewLayer ) { ClearGCode(); ClearLayers(); } setCurrentPrintingLine(0); m_model_changed.emit(); } }
void Model::ConvertToGCode() { if (is_calculating) { return; } is_calculating=true; // default: settings.SelectExtruder(0); Glib::TimeVal start_time; start_time.assign_current_time(); gcode.clear(); GCodeState state(gcode); Infill::clearPatterns(); Vector3d printOffset = settings.getPrintMargin(); double printOffsetZ = printOffset.z(); // Make Layers lastlayer = NULL; Slice(); //CleanupLayers(); MakeShells(); if (settings.get_boolean("Slicing","DoInfill") && !settings.get_boolean("Slicing","NoTopAndBottom") && (settings.get_double("Slicing","SolidThickness") > 0 || settings.get_integer("Slicing","ShellCount") > 0)) // not bridging when support MakeUncoveredPolygons( settings.get_boolean("Slicing","MakeDecor"), !settings.get_boolean("Slicing","NoBridges") && !settings.get_boolean("Slicing","Support") ); if (settings.get_boolean("Slicing","Support")) // easier before having multiplied uncovered bottoms MakeSupportPolygons(settings.get_double("Slicing","SupportWiden")); MakeFullSkins(); // must before multiplied uncovered bottoms MultiplyUncoveredPolygons(); if (settings.get_boolean("Slicing","Skirt")) MakeSkirt(); CalcInfill(); if (settings.get_boolean("Raft","Enable")) { printOffset += Vector3d (settings.get_double("Raft","Size"), 0); MakeRaft (state, printOffsetZ); // printOffsetZ will have height of raft added } state.ResetLastWhere(Vector3d(0,0,0)); uint count = layers.size(); m_progress->start (_("Making Lines"), count+1); state.AppendCommand(MILLIMETERSASUNITS, false, _("Millimeters")); state.AppendCommand(ABSOLUTEPOSITIONING, false, _("Absolute Pos")); if (settings.get_boolean("Slicing","RelativeEcode")) state.AppendCommand(RELATIVE_ECODE, false, _("Relative E Code")); else state.AppendCommand(ABSOLUTE_ECODE, false, _("Absolute E Code")); bool cont = true; vector<PLine3> plines; bool farthestStart = settings.get_boolean("Slicing","FarthestLayerStart"); Vector3d start = state.LastPosition(); for (uint p=0; p<count; p++) { cont = (m_progress->update(p)) ; if (!cont) break; // cerr << "GCode layer " << (p+1) << " of " << count // << " offset " << printOffsetZ // << " have commands: " <<commands.size() // << " start " << start << endl;; // try { if (farthestStart) { // Vector2d randstart = layers[p]->getRandomPolygonPoint(); // start.set(randstart.x(), randstart.y()); const Vector2d fartheststart = layers[p]->getFarthestPolygonPoint(start); start.set(fartheststart.x(), fartheststart.y()); } layers[p]->MakePrintlines(start, plines, printOffsetZ, settings); // } catch (Glib::Error &e) { // error("GCode Error:", (e.what()).c_str()); // } // if (layers[p]->getPrevious() != NULL) // cerr << p << ": " <<layers[p]->LayerNo << " prev: " // << layers[p]->getPrevious()->LayerNo << endl; } // do antiooze retract for all lines: Printlines::makeAntioozeRetract(plines, settings, m_progress); vector<Command> commands; //Printlines::getCommands(plines, settings, commands, m_progress); Printlines::getCommands(plines, settings, state, m_progress); //state.AppendCommands(commands, settings.Slicing.RelativeEcode); string GcodeTxt; if (cont) gcode.MakeText (GcodeTxt, settings, m_progress); else { ClearLayers(); ClearGCode(); ClearPreview(); } // display whole layer if flat shapes // if (shapes.back()->dimensions() == 2) // gcode.layerchanges.push_back(0); m_progress->stop (_("Done")); int h = (int)state.timeused/3600; int m = ((int)state.timeused%3600)/60; int s = ((int)state.timeused-3600*h-60*m); std::ostringstream ostr; ostr << _("Time Estimation: ") ; if (h>0) ostr << h <<_("h") ; ostr <<m <<_("m") <<s <<_("s") ; double gctime = gcode.GetTimeEstimation(); if (abs(state.timeused - gctime) > 10) { h = (int)(gctime/3600); m = ((int)gctime)%3600/60; s = (int)(gctime)-3600*h-60*m; ostr << _(" / GCode Estimation: "); if (h>0) ostr << h <<_("h"); ostr<< m <<_("m") << s <<_("s") ; } double totlength = gcode.GetTotalExtruded(settings.get_boolean("Slicing","RelativeEcode")); ostr << _(" - total extruded: ") << totlength << "mm"; // TODO: ths assumes all extruders use the same filament diameter const double diam = settings.get_double("Extruder","FilamentDiameter"); const double ccm = totlength * diam * diam / 4. * M_PI / 1000 ; ostr << " = " << ccm << "cm^3 "; ostr << "(ABS~" << ccm*1.08 << "g, PLA~" << ccm*1.25 << "g)"; if (statusbar) statusbar->push(ostr.str()); else cout << ostr.str() << endl; { Glib::TimeVal now; now.assign_current_time(); const int time_used = (int) round((now - start_time).as_double()); // seconds cerr << "GCode generated in " << time_used << " seconds. " << GcodeTxt.size() << " bytes" << endl; } is_calculating=false; m_signal_gcode_changed.emit(); }