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

Insert image to canvas via "Add image" tool, Select, Move and Scale the image #4897

Closed
yauhen-karmyzau opened this issue Jun 26, 2024 · 14 comments · Fixed by #5002
Closed

Insert image to canvas via "Add image" tool, Select, Move and Scale the image #4897

yauhen-karmyzau opened this issue Jun 26, 2024 · 14 comments · Fixed by #5002
Assignees
Labels
Images Images support MMPK Scope for Pathway reactions, View-only mode, Static images, Custom buttons and Ketcher API changes Test Cases Written Test cases has been written for that issue

Comments

@yauhen-karmyzau
Copy link
Collaborator

yauhen-karmyzau commented Jun 26, 2024

As a User, I want to be able to insert, select, scale and move images on the canvas so that I can enhance my chemical structure diagrams with relevant visuals and adjust them to fit my needs.

Acceptance Criteria:

  1. A user should be able to add an image using a dedicated 'Add Image' button located at the side panel with the static tools. The application should support at least the PNG image format and, if feasible, other commonly used image formats like JPEG, GIF, and SVG.

Image

  1. An image should be placed on the canvas on the click event under the mouse pointer.
  2. A user should be able to select an image by clicking on it with the selection and "Add Image" tools. The selected image should be visibly highlighted or outlined and the Scale functionality must be visible.
  3. A user should be able to scale (enlarge or reduce) a selected image using a dedicated 'Scale' option. The application should provide real-time feedback as the user scales an image.
  4. A user should be able to move a selected image around the canvas.
  5. After the image is inserted, moved or scaled, the user should be able to undo/redo his actions. The new size and position of the image must be saveable to supported formats (KET).
  6. If a user tries to upload an unsupported image format, they should be shown an error message. Moving and rotating images are out of scope for this user story.

TBD: Design of the image selection and UI elements for scaling.

#4897 (comment)

Ketcher is not support file insert from the system clipboard. This functionality may be implemented in scope of separate issue.

@yauhen-karmyzau
Copy link
Collaborator Author

Drag-n-Drop is out of scope! New feature need to be created.

@vanoprenko
Copy link
Collaborator

It doesn't make a lot of sense to deal with SVG as with raster. Let's either exclude it from scope (add with a separate ticket) or support as a vector.

@daniil-sloboda
Copy link
Collaborator

In case some images are not working due to size\format they are out of scope

@yauhen-karmyzau
Copy link
Collaborator Author

"stick to the mouse" - if too complex - out of scope.

@yauhen-karmyzau
Copy link
Collaborator Author

yauhen-karmyzau commented Jul 1, 2024

Team Agreement:
We can implement the same behaviour as for other "static tools:

  1. A User selects Insert image tool, the tool in the sidebar becomes active.
  2. A User clicks on the canvas and the system "select a file" window appears.
  3. When an image is uploaded , it appears at the place of the click.
  4. The tool in the sidebar becomes inactive when a User selects another tool. (Do we have any other scenarios?)

@yauhen-karmyzau
Copy link
Collaborator Author

Missed AC:

  • A User should be able to switch to Macro mode and back.
  • Images shouldn’t be visible in Micro.

@ivanmaslow
Copy link
Collaborator

ivanmaslow commented Jul 2, 2024

Missed AC:

  • User can zoom in and zoom out the canvas with an inserted image, while image is displayed according to the zoom and does not change its position;
  • Image can be selected using selection tools: rectangle, lasso, fragment:
    image
  • Image can be deleted using "Erase", "Clear Canvas" (Ctrl + Del) tools and buttons - Delete and Backspace;
  • User can Undo/Redo actions with images;
  • User can Copy/Cut/Delete images on the Canvas;

daniil-sloboda added a commit that referenced this issue Jul 4, 2024
@yauhen-karmyzau yauhen-karmyzau added the MMPK Scope for Pathway reactions, View-only mode, Static images, Custom buttons and Ketcher API changes label Jul 8, 2024
@ivanmaslow
Copy link
Collaborator

ivanmaslow commented Jul 8, 2024

Points below are discovered during exploratory testing on 08.07.24, need to be fixed:

  • User can't add the same picture several times using 'Add image' option
  • Need to update tooltip from 'Add image' to 'Add Image';
  • We are going to add white list for allowed formats (bmp, gif, jpeg, jpg, png, svg, webp);

@yauhen-karmyzau
Copy link
Collaborator Author

Ketcher is not support file insert from the system clipboard. This functionality may be implemented in scope of separate issue.

@yauhen-karmyzau yauhen-karmyzau changed the title Insert image to canvas Insert image to canvas via "Add image" tool Jul 8, 2024
daniil-sloboda added a commit that referenced this issue Jul 9, 2024
daniil-sloboda added a commit that referenced this issue Jul 10, 2024
@yauhen-karmyzau yauhen-karmyzau changed the title Insert image to canvas via "Add image" tool Insert image to canvas via "Add image" tool, Select, Move and Scale the image Jul 11, 2024
@ivanmaslow
Copy link
Collaborator

Points from the previous comment are fixed.
Points below are detected during exploratory testing on the nightly environment, need to be fixed:

  • When images are loaded from .ket file they can't be selected;
  • Can't delete the image;
  • Problem with selection on the intersection of 2 images.

@ivanmaslow
Copy link
Collaborator

ivanmaslow commented Jul 12, 2024

Points from the previous comment are fixed.
Points below are detected during exploratory testing on the nightly environment, need to be fixed:

@yauhen-karmyzau
Copy link
Collaborator Author

Change requests:

  1. Images should be displayed not in front, however, in back.
  2. Due to Indigo limitations, currently, we can save static image with PNG and SVG only, so the list of supported formats should be limited to this ones.

@ivanmaslow
Copy link
Collaborator

ivanmaslow commented Jul 22, 2024

Points from the previous comment except #5118 and #5097 are fixed.
New exploratory testing iteration after change request is completed on the Nightly env (4902 [Version 2.23.0-rc.1] Build at 2024-07-12; 10:06:35), points below are covered, tests are updated:

  • Allowed formats are PNG and SVG, in the case of other formats the error is displayed:
    image

  • Image with size less than 16 pixels can't be added to Canvas using "Add Image" button and error message is displayed - "Image should be at least 16x16 pixels"

  • "Add Image" button is on the left panel with tooltip:
    image

  • Images of allowed formats can be added to different selected places on Canvas (with previously added elements) one by one using "Add Image" button and they can be saved together to .ket file with the correct coordinates of images and sizes of files. Selected by user place on Canvas for image is the center of inserted image:
    image

  • Images of allowed formats can be added to different selected places on Canvas (with previously added elements) one by one using "Add Image" button and they can be selected and moved to other places on Canvas with appropriate layer level (including partial and complete overlap of elements);

  • If the image is selected then a green selection frame is displayed and the image can be scaled vertically, horizontally and diagonally using appropriate cursors:

  • Images of allowed formats after adding to Canvas using "Add Image" button supports the following actions:
    ->Zoom in/out (20, 400, 100);
    ->Deletion using "Clear Canvas" (or Ctrl+Delete) and "Erase" (or Delete, Backspace buttons);
    ->Copy-Paste, Cut-Paste;
    ->Undo/Redo of any action with image moving, scaling, deleting, or copying;

  • Images of allowed formats with elements can be saved to template and added to Canvas with correct position and layer level;

Remaining open defects have high priority and will be fixed in scope of next releases:

rrodionov91 pushed a commit that referenced this issue Jul 24, 2024
… Scale the image (#5002)

* #4911 - insert image from ket to canvas

* Loading image from ket file to canvas
* Saving image from struct to ket
* operations to move image during paste\replace

* #4911 - Fixing re rasterImage import

* #4911 - Fixed PR comments: string const, show, variable naming

* #4897 - adding image to canvas via addRasterImage tool

* #4897 - removed absolete console call from structLayout

* #4897 - fixed negative width\height

* #4897 - removed extra if

* #4897 - updated image properties, added lasso, closest selection

* #4897 - reset input value on load to allow user to upload the same image again

* #4897 - updated image tool text

* #4897 fixed selection function and updated image rendering logic

* #4897 updated tests snapshots

* #4897 - updated macromolecule mode snapshots

* #4902 - created selection for images

* #4902 - delete image, fixed image selection, moved text consts

* #4902 - image validation and selection fixes

* #4902 - updated closest logic to grab items under images easily

* #4902 - added gif to images allow list

* #4902 - raster image selection and movement on select and image tools

* #4902 - updated raster image validation

* #4902 - fixed import build errors

* #4902 - fixed rasterImages selection, templates, added testid

* #5039 - updated help.md and added image tool screenshot

* #4897 - changed images to render after the rest of the canvas items

* #4897 - changed images to render after the rest of the canvas items

* #4897 - updated supported formats

* #4897 - updated screenshot from merge conflict
@AlexeyGirin AlexeyGirin added the Test Cases Written Test cases has been written for that issue label Jul 25, 2024
@Zhirnoff
Copy link
Collaborator

Zhirnoff commented Aug 7, 2024

Tested.

Desktop:

  • OS: Windows 11
  • Browser Chrome
  • Version 124.0.6367.79 (Official Build) (64-bit)

Ketcher version
[Version 2.24.0-rc.1]
Indigo version
[Version 1.23.0-rc.1]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Images Images support MMPK Scope for Pathway reactions, View-only mode, Static images, Custom buttons and Ketcher API changes Test Cases Written Test cases has been written for that issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants