Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If a widget has been hidden using hide_widget, it will reappear after the view is zoom-out and zoom-in #411

Open
hmq2018 opened this issue Mar 3, 2024 · 1 comment
Labels

Comments

@hmq2018
Copy link

hmq2018 commented Mar 3, 2024

If a widget has been hidden using hide_widget, it will reappear after the viewer is zoom-out (very small) and zoom-in.

File: node_base.py

    def set_proxy_mode(self, mode):
        """
        Set whether to draw the node with proxy mode.
        (proxy mode toggles visibility for some qgraphic items in the node.)

        Args:
            mode (bool): true to enable proxy mode.
        """
       ...

        # node widget visibility.   =>need to add some conditions<=
        for w in self._widgets.values():
            w.widget().setVisible(visible)
@jchanvfx jchanvfx added the bug label Mar 3, 2024
@hmq2018 hmq2018 changed the title If a widget has been hidden using hide_widget, it will reappear after the view is zoom-in and zoom-out If a widget has been hidden using hide_widget, it will reappear after the view is zoom-out and zoom-in Mar 5, 2024
@serhaturtis
Copy link

Just in case anyone needs, if you don't need proxy mode and want to disable this behaviour, you can just edit the "auto_switch_mode" method in "node_base.py" to:

    def auto_switch_mode(self):
        """
        Decide whether to draw the node with proxy mode.
        (this is called at the start in the "self.paint()" function.)
        """
        if ITEM_CACHE_MODE is QtWidgets.QGraphicsItem.ItemCoordinateCache:
            return

        rect = self.sceneBoundingRect()
        l = self.viewer().mapToGlobal(
            self.viewer().mapFromScene(rect.topLeft()))
        r = self.viewer().mapToGlobal(
            self.viewer().mapFromScene(rect.topRight()))
        # width is the node width in screen
        width = r.x() - l.x()

        #self.set_proxy_mode(width < self._proxy_mode_threshold)
        # TODO: maybe limit zoom instead?
        self.set_proxy_mode(False)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants