Skip to content

Add Drag-and-Drop support and component deletion functionality#74

Open
krish-vj wants to merge 2 commits into
FOSSEE:masterfrom
krish-vj:master
Open

Add Drag-and-Drop support and component deletion functionality#74
krish-vj wants to merge 2 commits into
FOSSEE:masterfrom
krish-vj:master

Conversation

@krish-vj
Copy link
Copy Markdown

Overview

This PR introduces drag-and-drop support for adding components to the flowsheet canvas and adds deletion support for components and connections. It also resolves several stability issues related to component instantiation, coordinate mapping, and graphics item state handling.

Key Features

Drag-and-Drop Support

  • Users can now drag component buttons from the sidebar directly onto the canvas.
  • Components are instantiated at the exact drop location with proper viewport-to-scene coordinate mapping.
  • Provides visual drag feedback during placement.
  • Preserves the existing click-to-add workflow for quick component insertion.

Component & Connection Deletion

  • Keyboard Support: Selected components and streams can be deleted using the Delete or Backspace keys.
  • Context Menus: Added right-click Delete options for unit operations and stream connections.
  • Automatic Cleanup: Deleting a component removes all associated streams, dock widgets, and backend connections.
  • Undo/Redo Integration: All deletion operations are integrated with the existing undo/redo system.

Bug Fixes & Refactoring

Component Instantiation Fix

  • Fixed a TypeError caused by button signals passing incorrect arguments during component creation.

Graphics State Stability

  • Renamed the custom pos attribute to current_pos to avoid conflicts with Qt's built-in pos() method.
  • Resolved crashes related to graphics item state persistence and snapshot generation.

Drag-and-Drop Interaction

  • Added proper drag move event handling for the canvas viewport.
  • Fixed the invalid/forbidden cursor issue during drag-and-drop operations.

Files Modified

  1. src/main/python/mainApp.py

    • Added drag-and-drop handling, key event processing, and component instantiation improvements.
  2. src/main/python/utils/Container.py

    • Implemented robust component and connection deletion logic.
  3. src/main/python/utils/Graphics.py

    • Added context menu actions and resolved graphics attribute conflicts.
  4. src/main/python/utils/UnitOperations.py

    • Added backend connection cleanup through the new remove_connection functionality.
  5. undo_redo/*

    • Integrated deletion actions with the existing undo/redo framework.

Testing

  • Verified drag-and-drop placement of components on the canvas.
  • Verified existing click-to-add functionality remains operational.
  • Verified deletion of components using Delete/Backspace keys.
  • Verified deletion through context menu actions.
  • Verified cleanup of associated connections during component deletion.
  • Verified undo/redo functionality after deletion operations.
  • Confirmed correct coordinate mapping during drag-and-drop placement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant