Commit ab91d1b6 authored by Guillaume Seguin's avatar Guillaume Seguin

Use gcode reported dims to fit on object

parent a965554f
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with Printrun. If not, see <http://www.gnu.org/licenses/>. # along with Printrun. If not, see <http://www.gnu.org/licenses/>.
import wx import wx
from . import gcoder from . import gcoder
...@@ -37,6 +36,11 @@ def create_model(light): ...@@ -37,6 +36,11 @@ def create_model(light):
else: else:
return actors.GcodeModel() return actors.GcodeModel()
def gcode_dims(g):
return ((g.xmin, g.xmax, g.width),
(g.ymin, g.ymax, g.depth),
(g.zmin, g.zmax, g.height))
def set_model_colors(model, root): def set_model_colors(model, root):
for field in dir(model): for field in dir(model):
if field.startswith("color_"): if field.startswith("color_"):
...@@ -212,7 +216,7 @@ class GcodeViewPanel(wxGLPanel): ...@@ -212,7 +216,7 @@ class GcodeViewPanel(wxGLPanel):
if not self.parent.model or not self.parent.model.loaded: if not self.parent.model or not self.parent.model.loaded:
return return
self.canvas.SetCurrent(self.context) self.canvas.SetCurrent(self.context)
dims = self.parent.model.dims dims = gcode_dims(self.parent.model.gcode)
self.reset_mview(1.0) self.reset_mview(1.0)
center_x = (dims[0][0] + dims[0][1]) / 2 center_x = (dims[0][0] + dims[0][1]) / 2
center_y = (dims[1][0] + dims[1][1]) / 2 center_y = (dims[1][0] + dims[1][1]) / 2
......
...@@ -333,6 +333,8 @@ class GcodeModel(Model): ...@@ -333,6 +333,8 @@ class GcodeModel(Model):
use_vbos = True use_vbos = True
loaded = False loaded = False
gcode = None
path_halfwidth = 0.2 path_halfwidth = 0.2
path_halfheight = 0.2 path_halfheight = 0.2
...@@ -343,6 +345,7 @@ class GcodeModel(Model): ...@@ -343,6 +345,7 @@ class GcodeModel(Model):
def load_data(self, model_data, callback=None): def load_data(self, model_data, callback=None):
t_start = time.time() t_start = time.time()
self.gcode = model_data
self.count_travel_indices = count_travel_indices = [0] self.count_travel_indices = count_travel_indices = [0]
self.count_print_indices = count_print_indices = [0] self.count_print_indices = count_print_indices = [0]
...@@ -741,8 +744,11 @@ class GcodeModelLight(Model): ...@@ -741,8 +744,11 @@ class GcodeModelLight(Model):
use_vbos = True use_vbos = True
loaded = False loaded = False
gcode = None
def load_data(self, model_data, callback=None): def load_data(self, model_data, callback=None):
t_start = time.time() t_start = time.time()
self.gcode = model_data
self.layer_idxs_map = {} self.layer_idxs_map = {}
self.layer_stops = [0] self.layer_stops = [0]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment