- modified the way that the plotcanvas widget is added
This commit is contained in:
@@ -2663,7 +2663,7 @@ class FCDetachableTab(QtWidgets.QTabWidget):
|
||||
From here:
|
||||
https://stackoverflow.com/questions/47267195/in-pyqt4-is-it-possible-to-detach-tabs-from-a-qtabwidget
|
||||
"""
|
||||
tab_detached = QtCore.pyqtSignal(str)
|
||||
tab_detached = QtCore.pyqtSignal(QtWidgets.QWidget, str)
|
||||
tab_attached = QtCore.pyqtSignal(str)
|
||||
|
||||
def __init__(self, protect=None, protect_by_name=None, parent=None):
|
||||
@@ -2845,7 +2845,7 @@ class FCDetachableTab(QtWidgets.QTabWidget):
|
||||
# Create a reference to maintain access to the detached tab
|
||||
self.detachedTabs[name] = detachedTab
|
||||
|
||||
self.tab_detached.emit(name)
|
||||
self.tab_detached.emit(detachedTab, name)
|
||||
|
||||
def attachTab(self, contentWidget, name, icon, insertAt=None):
|
||||
"""
|
||||
@@ -3033,8 +3033,16 @@ class FCDetachableTab(QtWidgets.QTabWidget):
|
||||
self.setObjectName(name)
|
||||
self.setWindowTitle(name)
|
||||
|
||||
# create a widget to be set as centraWidget
|
||||
self.c_widget = QtWidgets.QWidget()
|
||||
self.central_layout = QtWidgets.QVBoxLayout()
|
||||
self.c_widget.setLayout(self.central_layout)
|
||||
|
||||
# add our widget to the central layout
|
||||
self.contentWidget = contentWidget
|
||||
self.setCentralWidget(self.contentWidget)
|
||||
self.central_layout.addWidget(self.contentWidget)
|
||||
|
||||
self.setCentralWidget(self.c_widget)
|
||||
self.contentWidget.show()
|
||||
|
||||
self.windowDropFilter = self.WindowDropFilter()
|
||||
|
||||
@@ -31,13 +31,12 @@ class PlotCanvas(QtCore.QObject, VisPyCanvas):
|
||||
Class handling the plotting area in the application.
|
||||
"""
|
||||
|
||||
def __init__(self, container, fcapp):
|
||||
def __init__(self, fcapp):
|
||||
"""
|
||||
The constructor configures the VisPy figure that
|
||||
will contain all plots, creates the base axes and connects
|
||||
events to the plotting area.
|
||||
|
||||
:param container: The parent container in which to draw plots.
|
||||
:rtype: PlotCanvas
|
||||
"""
|
||||
|
||||
@@ -51,9 +50,6 @@ class PlotCanvas(QtCore.QObject, VisPyCanvas):
|
||||
|
||||
self.fcapp = fcapp
|
||||
|
||||
# Parent container
|
||||
self.container = container
|
||||
|
||||
settings = QtCore.QSettings("Open Source", "FlatCAM")
|
||||
if settings.contains("theme"):
|
||||
theme = settings.value('theme', type=str)
|
||||
@@ -131,9 +127,6 @@ class PlotCanvas(QtCore.QObject, VisPyCanvas):
|
||||
self.create_native()
|
||||
self.native.setParent(self.fcapp.ui)
|
||||
|
||||
# <QtCore.QObject>
|
||||
self.container.addWidget(self.native)
|
||||
|
||||
# ## AXIS # ##
|
||||
self.v_line = InfiniteLine(pos=0, color=(0.70, 0.3, 0.3, 0.8), vertical=True,
|
||||
parent=self.view.scene)
|
||||
@@ -212,12 +205,21 @@ class PlotCanvas(QtCore.QObject, VisPyCanvas):
|
||||
|
||||
self.c = None
|
||||
self.big_cursor = None
|
||||
|
||||
# Parent container
|
||||
# self.container = container
|
||||
|
||||
# Keep VisPy canvas happy by letting it be "frozen" again.
|
||||
self.freeze()
|
||||
|
||||
# fit everything into view
|
||||
self.fit_view()
|
||||
|
||||
self.graph_event_connect('mouse_wheel', self.on_mouse_scroll)
|
||||
|
||||
# <QtCore.QObject>
|
||||
# self.container.addWidget(self.native)
|
||||
|
||||
def on_toggle_axis(self, signal=None, state=None, silent=None):
|
||||
if not state:
|
||||
state = not self.axis_enabled
|
||||
|
||||
@@ -132,13 +132,12 @@ class PlotCanvasLegacy(QtCore.QObject):
|
||||
|
||||
double_click = QtCore.pyqtSignal(object)
|
||||
|
||||
def __init__(self, container, app):
|
||||
def __init__(self, app):
|
||||
"""
|
||||
The constructor configures the Matplotlib figure that
|
||||
will contain all plots, creates the base axes and connects
|
||||
events to the plotting area.
|
||||
|
||||
:param container: The parent container in which to draw plots.
|
||||
:rtype: PlotCanvas
|
||||
"""
|
||||
|
||||
@@ -220,7 +219,7 @@ class PlotCanvasLegacy(QtCore.QObject):
|
||||
self.y_margin = 25 # Pixels
|
||||
|
||||
# Parent container
|
||||
self.container = container
|
||||
# self.container = container
|
||||
|
||||
# Plots go onto a single matplotlib.figure
|
||||
self.figure = Figure(dpi=50)
|
||||
@@ -257,10 +256,6 @@ class PlotCanvasLegacy(QtCore.QObject):
|
||||
self.adjust_axes(-10, -10, 100, 100)
|
||||
# self.canvas.set_can_focus(True) # For key press
|
||||
|
||||
# Attach to parent
|
||||
# self.container.attach(self.canvas, 0, 0, 600, 400)
|
||||
self.container.addWidget(self.canvas) # Qt
|
||||
|
||||
# Copy a bitmap of the canvas for quick animation.
|
||||
# Update every time the canvas is re-drawn.
|
||||
self.background = self.canvas.copy_from_bbox(self.axes.bbox)
|
||||
@@ -334,6 +329,11 @@ class PlotCanvasLegacy(QtCore.QObject):
|
||||
}
|
||||
""")
|
||||
|
||||
# Attach to parent
|
||||
self.native = self.canvas # for API compatibility with 3D plotcanvas
|
||||
# self.container.attach(self.canvas, 0, 0, 600, 400)
|
||||
# self.container.addWidget(self.canvas) # Qt
|
||||
|
||||
def on_toggle_axis(self, signal=None, state=None, silent=None):
|
||||
if not state:
|
||||
state = not self.axis_enabled
|
||||
|
||||
Reference in New Issue
Block a user