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

#3728 - Add group selection for macromolecules #3879

Merged
merged 3 commits into from
Jan 17, 2024

Conversation

Balzamova
Copy link
Collaborator

How the feature works? / How did you fix the issue?

(Screenshots, videos, or GIFs, if applicable)

Check list

  • unit-tests written
  • e2e-tests written
  • documentation updated
  • PR name follows the pattern #1234 – issue name
  • branch name doesn't contain '#'
  • PR is linked with the issue
  • base branch (master or release/xx) is correct
  • task status changed to "Code review"
  • reviewers are notified about the pull request

Comment on lines 178 to 204
public selectCurrentDrawingEntities(drawingEntity: DrawingEntity) {
const command = new Command();

this.allEntities.forEach(([, drawingEntity]) => {
if (drawingEntity.selected) {
const operation = new DrawingEntitySelectOperation(drawingEntity);
command.addOperation(operation);
}
});

if (drawingEntity.selected) {
drawingEntity.turnOffSelection();
const operation = new DrawingEntitySelectOperation(drawingEntity);
command.addOperation(operation);
} else {
drawingEntity.turnOnSelection();
const operation = new DrawingEntitySelectOperation(drawingEntity);
command.addOperation(operation);
}

return command;
}

Copy link
Contributor

@ilya-asiyuk-epam ilya-asiyuk-epam Jan 17, 2024

Choose a reason for hiding this comment

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

I suggest below changes:

private addOperationToCommand(
    command: Command,
    drawingEntity: DrawingEntity,
  ) {
    const operation = new DrawingEntitySelectOperation(drawingEntity);
    command.addOperation(operation);
  }

  public selectCurrentDrawingEntities(drawingEntity: DrawingEntity) {
    const command = new Command();

    this.allEntities.forEach(([, drawingEntity]) => {
      if (drawingEntity.selected) {
        this.addOperationToCommand(command, drawingEntity);
      }
    });

    if (drawingEntity.selected) {
      drawingEntity.turnOffSelection();
    } else {
      drawingEntity.turnOnSelection();
    }
    this.addOperationToCommand(command, drawingEntity);

    return command;
  }

Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe that addOperationToCommand is not the best name for this method, because it actually adds concrete DrawingEntitySelectOperation.
However I would propose to not create this method at all. We can do like this in selectCurrentDrawingEntities method:

      command.addOperation(
         new DrawingEntitySelectOperation(drawingEntity)
      );

@Balzamova Balzamova force-pushed the 3728-adding-group-selection branch from 65ef360 to f6c3698 Compare January 17, 2024 15:46
@Balzamova Balzamova force-pushed the 3728-adding-group-selection branch from f6c3698 to b313673 Compare January 17, 2024 17:55
@Balzamova Balzamova merged commit 5ce5bac into master Jan 17, 2024
5 checks passed
@Balzamova Balzamova deleted the 3728-adding-group-selection branch January 17, 2024 18:26
Comment on lines +186 to +203
public selectCurrentDrawingEntities(drawingEntity: DrawingEntity) {
const command = new Command();

this.allEntities.forEach(([, drawingEntity]) => {
if (drawingEntity.selected) {
this.addOperationToCommand(command, drawingEntity);
}
});

if (drawingEntity.selected) {
drawingEntity.turnOffSelection();
} else {
drawingEntity.turnOnSelection();
}
this.addOperationToCommand(command, drawingEntity);

return command;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

It looks like a bit overhead to create operations for already selected entities. Can we rework and rename this method to add only one drawing entity to selection?

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.

Macro: Group selection using Shift+LClick is not implemented
3 participants