-
Notifications
You must be signed in to change notification settings - Fork 272
Update plotter.py #1209
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
Update plotter.py #1209
Conversation
Use the specified mode not mode in settings.
WalkthroughThe changes in this pull request focus on the Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Plotter
User->>Plotter: Call background(c1, c2, at, mode)
Plotter->>Plotter: Set gradient background using mode argument
Plotter-->>User: Render background
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (2)
vedo/plotter.py (2)
1211-1212
: Implementation looks good but needs additional error handlingThe gradient mode setting implementation works correctly but could benefit from additional error handling for invalid mode values.
Consider adding validation and error handling:
- r.SetGradientMode(modes[mode]) + if 0 <= mode < len(modes): + r.SetGradientMode(modes[mode]) + else: + vedo.logger.warning(f"Invalid gradient mode {mode}. Using default mode 0.") + r.SetGradientMode(modes[0])
1211-1212
: Consider improving code organization and error handlingThe gradient modes list could be defined as a class/module level constant and the error handling could be more informative.
Consider refactoring to:
+ # At class/module level + GRADIENT_MODES = [ + vtki.vtkViewport.GradientModes.VTK_GRADIENT_VERTICAL, + vtki.vtkViewport.GradientModes.VTK_GRADIENT_HORIZONTAL, + vtki.vtkViewport.GradientModes.VTK_GRADIENT_RADIAL_VIEWPORT_FARTHEST_SIDE, + vtki.vtkViewport.GradientModes.VTK_GRADIENT_RADIAL_VIEWPORT_FARTHEST_CORNER, + ] # In background() method try: - modes = [ - vtki.vtkViewport.GradientModes.VTK_GRADIENT_VERTICAL, - vtki.vtkViewport.GradientModes.VTK_GRADIENT_HORIZONTAL, - vtki.vtkViewport.GradientModes.VTK_GRADIENT_RADIAL_VIEWPORT_FARTHEST_SIDE, - vtki.vtkViewport.GradientModes.VTK_GRADIENT_RADIAL_VIEWPORT_FARTHEST_CORNER, - ] - r.SetGradientMode(modes[mode]) + if 0 <= mode < len(GRADIENT_MODES): + r.SetGradientMode(GRADIENT_MODES[mode]) + else: + vedo.logger.warning(f"Invalid gradient mode {mode}. Using default mode 0.") + r.SetGradientMode(GRADIENT_MODES[0]) except AttributeError: - pass + vedo.logger.warning("Gradient mode setting requires VTK >= 9.3")
Use the specified mode not mode in settings.