- print() debugging

This commit is contained in:
Marius Stanciu 2020-01-10 13:00:47 +02:00
parent 8c33f6e0be
commit 2ff9cd2439
3 changed files with 25 additions and 28 deletions

View File

@ -11983,7 +11983,7 @@ class App(QtCore.QObject):
plot_container = container
else:
plot_container = self.ui.right_layout
print("step_1")
if self.is_legacy is False:
try:
self.plotcanvas = PlotCanvas(plot_container, self)
@ -11999,11 +11999,9 @@ class App(QtCore.QObject):
return 'fail'
else:
self.plotcanvas = PlotCanvasLegacy(plot_container, self)
print("step_2")
# So it can receive key presses
self.plotcanvas.native.setFocus()
print("step_3")
self.mm = self.plotcanvas.graph_event_connect('mouse_move', self.on_mouse_move_over_plot)
self.mp = self.plotcanvas.graph_event_connect('mouse_press', self.on_mouse_click_over_plot)
@ -12012,28 +12010,22 @@ class App(QtCore.QObject):
# Keys over plot enabled
self.kp = self.plotcanvas.graph_event_connect('key_press', self.ui.keyPressEvent)
print("step_4")
if self.defaults['global_cursor_type'] == 'small':
self.app_cursor = self.plotcanvas.new_cursor()
else:
self.app_cursor = self.plotcanvas.new_cursor(big=True)
print("step_5")
if self.ui.grid_snap_btn.isChecked():
self.app_cursor.enabled = True
else:
self.app_cursor.enabled = False
print("step_6")
if self.is_legacy is False:
self.hover_shapes = ShapeCollection(parent=self.plotcanvas.view.scene, layers=1)
else:
# will use the default Matplotlib axes
self.hover_shapes = ShapeCollectionLegacy(obj=self, app=self, name='hover')
print("step_7")
def on_zoom_fit(self, event):
"""

View File

@ -32,11 +32,11 @@ class PlotCanvas(QtCore.QObject, VisPyCanvas):
:param container: The parent container in which to draw plots.
:rtype: PlotCanvas
"""
print("step_1_1")
super(PlotCanvas, self).__init__()
# super(PlotCanvas, self).__init__()
# QtCore.QObject.__init__(self)
# VisPyCanvas.__init__(self)
print("step_1_2")
super().__init__()
# VisPyCanvas does not allow new attributes. Override.
self.unfreeze()
@ -46,8 +46,6 @@ class PlotCanvas(QtCore.QObject, VisPyCanvas):
# Parent container
self.container = container
print("step_1_3")
settings = QtCore.QSettings("Open Source", "FlatCAM")
if settings.contains("theme"):
theme = settings.value('theme', type=str)
@ -117,8 +115,6 @@ class PlotCanvas(QtCore.QObject, VisPyCanvas):
}
)
print("step_1_4")
# <VisPyCanvas>
self.create_native()
self.native.setParent(self.fcapp.ui)
@ -126,8 +122,6 @@ class PlotCanvas(QtCore.QObject, VisPyCanvas):
# <QtCore.QObject>
self.container.addWidget(self.native)
print("step_1_5")
# ## AXIS # ##
self.v_line = InfiniteLine(pos=0, color=(0.70, 0.3, 0.3, 0.8), vertical=True,
parent=self.view.scene)
@ -135,15 +129,11 @@ class PlotCanvas(QtCore.QObject, VisPyCanvas):
self.h_line = InfiniteLine(pos=0, color=(0.70, 0.3, 0.3, 0.8), vertical=False,
parent=self.view.scene)
print("step_1_6")
# draw a rectangle made out of 4 lines on the canvas to serve as a hint for the work area
# all CNC have a limited workspace
if self.fcapp.defaults['global_workspace'] is True:
self.draw_workspace(workspace_size=self.fcapp.defaults["global_workspaceT"])
print("step_1_7")
self.line_parent = None
if self.fcapp.defaults["global_cursor_color_enabled"]:
c_color = Color(self.fcapp.defaults["global_cursor_color"]).rgba
@ -156,8 +146,6 @@ class PlotCanvas(QtCore.QObject, VisPyCanvas):
self.cursor_h_line = InfiniteLine(pos=None, color=c_color, vertical=False,
parent=self.line_parent)
print("step_1_8")
self.shape_collections = []
self.shape_collection = self.new_shape_collection()
@ -171,10 +159,7 @@ class PlotCanvas(QtCore.QObject, VisPyCanvas):
self.big_cursor = None
# Keep VisPy canvas happy by letting it be "frozen" again.
self.freeze()
print("step_1_9")
self.fit_view()
print("step_1_10")
self.graph_event_connect('mouse_wheel', self.on_mouse_scroll)

View File

@ -24,15 +24,24 @@ black = Color("#000000")
class VisPyCanvas(scene.SceneCanvas):
def __init__(self, config=None):
scene.SceneCanvas.__init__(self, keys=None, config=config)
print("vp_1")
try:
# scene.SceneCanvas.__init__(self, keys=None, config=config)
super().__init__(config=config, keys=None)
except Exception as e:
print("VisPyCanvas.__init__() -> %s" % str(e))
print("vp_2")
self.unfreeze()
print("vp_3")
settings = QSettings("Open Source", "FlatCAM")
if settings.contains("axis_font_size"):
a_fsize = settings.value('axis_font_size', type=int)
else:
a_fsize = 8
print("vp_4")
if settings.contains("theme"):
theme = settings.value('theme', type=str)
@ -50,6 +59,8 @@ class VisPyCanvas(scene.SceneCanvas):
# back_color = Color('#272822') # darker
# back_color = Color('#3c3f41') # lighter
print("vp_5")
self.central_widget.bgcolor = back_color
self.central_widget.border_color = back_color
@ -59,6 +70,8 @@ class VisPyCanvas(scene.SceneCanvas):
top_padding = self.grid_widget.add_widget(row=0, col=0, col_span=2)
top_padding.height_max = 0
print("vp_6")
self.yaxis = scene.AxisWidget(
orientation='left', axis_color=tick_color, text_color=tick_color, font_size=a_fsize, axis_width=1
)
@ -76,9 +89,13 @@ class VisPyCanvas(scene.SceneCanvas):
# right_padding.width_max = 24
right_padding.width_max = 0
print("vp_7")
view = self.grid_widget.add_view(row=1, col=1, border_color=tick_color, bgcolor=theme_color)
view.camera = Camera(aspect=1, rect=(-25, -25, 150, 150))
print("vp_8")
# Following function was removed from 'prepare_draw()' of 'Grid' class by patch,
# it is necessary to call manually
self.grid_widget._update_child_widget_dim()
@ -101,7 +118,10 @@ class VisPyCanvas(scene.SceneCanvas):
else:
self.grid = scene.GridLines(parent=self.view.scene, color='#dededeff')
print("vp_9")
self.grid.set_gl_state(depth_test=False)
print("vp_10")
self.freeze()