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

Update lower knit display #674

Merged
merged 11 commits into from
Jul 15, 2024
Merged

Update lower knit display #674

merged 11 commits into from
Jul 15, 2024

Conversation

X-sam
Copy link
Member

@X-sam X-sam commented Jul 8, 2024

Update the lower knit progress display:

  • Add sticky headers on the top and left side
  • Fix horizontal scrolling.
  • In Multicolor mode, colors the background of the knit progress view to show needles, alternating every 10 stitches.
  • Adds color indication for current pass to the knit progress headers & the lower label.
  • Adds a separator to delineate the row yet to-be-set.
  • Adds a density preference, allowing for user-set stitch widths on the lower display.

Density 20:
Screenshot 2024-07-14 232134

Density 5:
Screenshot 2024-07-14 231850

This addresses #668 #646 #615

Summary by CodeRabbit

  • New Features

    • Enhanced progress bar update functionality using a Status object for more efficient data handling.
  • Bug Fixes

    • Fixed inconsistencies in the status update mechanism.
  • UI Improvements

    • Updated UI elements in the knitting progress display, including table layout and color handling.
  • Preferences

    • Introduced a new integer preference for lower_display_stitch_width.
    • Added new widget class for managing integer preferences.
  • Code Refactor

    • Streamlined multiple methods to use Status objects instead of passing individual attributes.

Copy link
Contributor

coderabbitai bot commented Jul 8, 2024

Walkthrough

The recent updates include adjustments to the Control, Engine, Status, knitprogress, preferences, and progressbar components in the AYAB engine. Primarily, these modifications focus on encapsulating status attributes into a Status object for streamlined data handling and consistency across various methods and UI updates. Additionally, new preferences and integer handling functionalities were introduced, enhancing user customization options.

Changes

File Change Summary
src/main/python/ayab/engine/control.py Added assignment self.status.total_rows = self.pat_height before updating other status attributes in the cnf_line_API6 method
src/main/python/ayab/engine/engine.py knit_config and __handle_status methods now use a Status object for progress updates
src/main/python/ayab/engine/status.py Added total_rows and mirror attributes to the copy method in the Status class
src/main/python/main/ayab/knitprogress.py Modified UI elements and logic, including new methods for row header formatting and stitch rendering
src/main/python/main/ayab/preferences.py Introduced lower_display_stitch_width preference and related updates, added PrefsIntWidget class for handling integer preferences
src/main/python/main/ayab/progressbar.py Updated ProgressBar class to use a Status object for the update method and added color handling functionality

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant GUI
    participant Control
    participant Engine
    participant Status
    participant ProgressBar

    User->>GUI: Initiates knitting process
    GUI->>Engine: Call knit_config with image
    Engine->>Status: Initialize Status object
    Status-->>Engine: Status object with attributes
    Engine->>ProgressBar: emit_progress_bar_updater(Status)
    ProgressBar->>GUI: Update progress bar using Status
    GUI->>User: Display updated progress
Loading

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?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between b30edbc and 71cf682.

Files selected for processing (7)
  • src/main/python/ayab/engine/control.py (1 hunks)
  • src/main/python/ayab/engine/engine.py (2 hunks)
  • src/main/python/ayab/engine/status.py (1 hunks)
  • src/main/python/ayab/knitprogress.py (4 hunks)
  • src/main/python/ayab/progressbar.py (3 hunks)
  • src/main/python/ayab/signal_receiver.py (1 hunks)
  • src/main/python/ayab/signal_sender.py (1 hunks)
Additional context used
Ruff
src/main/python/ayab/progressbar.py

73-75: Use ternary operator fgColor = 16777215 if bgColor.lightness() < 128 else 0 instead of if-else-block

Replace if-else-block with fgColor = 16777215 if bgColor.lightness() < 128 else 0

(SIM108)


75-75: Multiple statements on one line (colon)

(E701)

src/main/python/ayab/knitprogress.py

22-22: PySide6.QtCore.QSize imported but unused

Remove unused import: PySide6.QtCore.QSize

(F401)


23-23: PySide6.QtWidgets.QLabel imported but unused

Remove unused import: PySide6.QtWidgets.QLabel

(F401)

Additional comments not posted (12)
src/main/python/ayab/progressbar.py (3)

23-23: LGTM!

The import statement for QColor is necessary for the new backgroundColor attribute.


44-44: LGTM!

The addition of the backgroundColor attribute in the constructor is necessary for the new functionality.


51-59: LGTM!

The update method now accepts a Status object, aligning with the encapsulation of status information and improving maintainability.

src/main/python/ayab/signal_receiver.py (1)

46-46: LGTM!

The progress_bar_updater signal now accepts a Status object, aligning with the encapsulation of status information and improving maintainability.

src/main/python/ayab/signal_sender.py (1)

53-56: LGTM!

The emit_progress_bar_updater method now accepts a Status object, aligning with the encapsulation of status information and improving maintainability.

src/main/python/ayab/engine/status.py (1)

168-169: LGTM!

The copy method now includes the total_rows and mirror attributes, ensuring these attributes are copied when the method is called.

src/main/python/ayab/knitprogress.py (3)

96-98: Verify the usage of the auto_mirror parameter.

The auto_mirror parameter is marked as unused. Ensure that this is intentional or remove it if not needed.


99-104: Approve changes to progress information display.

The changes to include detailed progress information enhance the clarity of the progress display.


175-185: Approve the addition of the bg_color parameter.

The addition of the bg_color parameter provides more flexibility in setting the background color of the stitch.

src/main/python/ayab/engine/engine.py (2)

145-147: Approve the encapsulation of status updates.

The changes to create a Status object and pass it to emit_progress_bar_updater improve the encapsulation and handling of status updates.


217-217: Approve the encapsulation of status updates.

The changes to create a Status object and pass it to emit_progress_bar_updater improve the encapsulation and handling of status updates.

src/main/python/ayab/engine/control.py (1)

246-246: Approve the update to total_rows.

The change to assign self.status.total_rows to self.pat_height ensures that the total number of rows is updated correctly.

src/main/python/ayab/knitprogress.py Outdated Show resolved Hide resolved
src/main/python/ayab/progressbar.py Outdated Show resolved Hide resolved
src/main/python/ayab/progressbar.py Outdated Show resolved Hide resolved
@X-sam X-sam force-pushed the knit-display-updates branch from 71cf682 to 8ca4b01 Compare July 8, 2024 13:02
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Outside diff range and nitpick comments (1)
src/main/python/main/ayab/progressbar.py (1)

51-51: Optimize the method signature.

The method signature can be simplified by removing the line break.

- def update(
-     self,
-     status: Status
- ) -> bool:
+ def update(self, status: Status) -> bool:
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 71cf682 and 42f09c2.

Files selected for processing (8)
  • src/main/python/main/ayab/ayab.py (2 hunks)
  • src/main/python/main/ayab/engine/control.py (1 hunks)
  • src/main/python/main/ayab/engine/engine.py (2 hunks)
  • src/main/python/main/ayab/engine/status.py (1 hunks)
  • src/main/python/main/ayab/knitprogress.py (4 hunks)
  • src/main/python/main/ayab/progressbar.py (3 hunks)
  • src/main/python/main/ayab/signal_receiver.py (1 hunks)
  • src/main/python/main/ayab/signal_sender.py (1 hunks)
Additional context used
Ruff
src/main/python/main/ayab/progressbar.py

73-75: Use ternary operator fgColor = 16777215 if bgColor.lightness() < 128 else 0 instead of if-else-block

Replace if-else-block with fgColor = 16777215 if bgColor.lightness() < 128 else 0

(SIM108)


75-75: Multiple statements on one line (colon)

(E701)

Additional comments not posted (11)
src/main/python/main/ayab/signal_receiver.py (1)

46-46: LGTM! Ensure correct signal connections.

The changes to the progress_bar_updater signal are consistent with the rest of the code.

Ensure that all connections in the activate_signals method are correct.

src/main/python/main/ayab/signal_sender.py (1)

53-56: LGTM! Ensure proper handling of Status object.

The changes to the emit_progress_bar_updater method are consistent with the rest of the code.

Ensure that the Status object is properly handled within the method.

src/main/python/main/ayab/engine/status.py (1)

168-169: LGTM! Ensure proper handling of new attributes.

The changes to the copy method are consistent with the rest of the code.

Ensure that the total_rows and mirror attributes are properly handled within the method.

src/main/python/main/ayab/ayab.py (2)

179-179: LGTM!

The progress bar is now updated with the engine status, which improves the synchronization of the UI with the engine state.


193-194: LGTM!

The engine status is now updated with the start row, and the progress bar is updated accordingly. This ensures the progress bar accurately reflects the current row.

src/main/python/main/ayab/knitprogress.py (3)

144-170: LGTM!

The new method format_row_header_text enhances the readability and information display of the row headers by incorporating various status attributes.


172-182: LGTM!

The changes improve the visual representation of the stitches by updating the background color based on the status.


93-133: LGTM! Verify the new method usage.

The changes improve the clarity and functionality of the progress display. The addition of the format_row_header_text method and the updated logic for stitching elements enhance the UI.

Ensure that the new method format_row_header_text is used correctly throughout the codebase.

src/main/python/main/ayab/engine/engine.py (2)

145-147: LGTM!

The change ensures that the progress bar is updated with a Status object, encapsulating the relevant data and improving data handling.


217-217: LGTM!

The change ensures that the progress bar is updated with a Status object, encapsulating the relevant data and improving data handling.

src/main/python/main/ayab/engine/control.py (1)

246-246: LGTM!

The change ensures that the total rows are accurately reflected in the status, improving the accuracy of the status updates.

src/main/python/main/ayab/progressbar.py Outdated Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 42f09c2 and 3381902.

Files selected for processing (2)
  • src/main/python/main/ayab/knitprogress.py (3 hunks)
  • src/main/python/main/ayab/preferences.py (11 hunks)
Files skipped from review as they are similar to previous changes (1)
  • src/main/python/main/ayab/knitprogress.py
Additional comments not posted (6)
src/main/python/main/ayab/preferences.py (6)

70-70: New type alias PreferencesDictIntKeys looks good.

The type alias is correctly defined and follows the existing pattern.


75-75: Updated type alias PreferencesDictKeys looks good.

The update is consistent with the existing type alias definitions and correctly includes the new type alias.


91-91: Updated PreferencesDict looks good.

The update is correctly formatted and follows the existing pattern of the dictionary.


121-121: Updated variables dictionary in Preferences class looks good.

The update is correctly formatted and follows the existing pattern of the dictionary.


166-166: Updated convert method in Preferences class looks good.

The update is correctly formatted and follows the existing pattern of the method.


279-299: New class PrefsIntWidget looks good.

The class is well-defined and follows the pattern of other preference widget classes in the file. The methods are correctly implemented.

Copy link

@X-sam X-sam linked an issue Jul 15, 2024 that may be closed by this pull request
@X-sam
Copy link
Member Author

X-sam commented Jul 15, 2024

@coderabbitai review

Copy link
Contributor

coderabbitai bot commented Jul 15, 2024

Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 3381902 and 3bed1bc.

Files selected for processing (2)
  • src/main/python/main/ayab/knitprogress.py (3 hunks)
  • src/main/python/main/ayab/progressbar.py (3 hunks)
Files skipped from review as they are similar to previous changes (1)
  • src/main/python/main/ayab/knitprogress.py
Additional context used
Ruff
src/main/python/main/ayab/progressbar.py

73-75: Use ternary operator fg_color = 16777215 if bg_color.lightness() < 128 else 0 instead of if-else-block

Replace if-else-block with fg_color = 16777215 if bg_color.lightness() < 128 else 0

(SIM108)


75-75: Multiple statements on one line (colon)

(E701)

Additional comments not posted (2)
src/main/python/main/ayab/progressbar.py (2)

23-23: LGTM!

The import of QColor and Status is appropriate and aligns with the changes in the update method.

Also applies to: 27-27


51-59: LGTM! But verify the method calls.

The code changes are approved.

However, ensure that all calls to the update method pass a Status object.

src/main/python/main/ayab/progressbar.py Show resolved Hide resolved
@dl1com dl1com merged commit bc96d5c into 1.0.0-dev Jul 15, 2024
9 checks passed
@dl1com dl1com deleted the knit-display-updates branch July 15, 2024 20:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants