Skip to content

Conversation

@Zaitam
Copy link

@Zaitam Zaitam commented May 4, 2025

Introduces shape recognition functionality to enhance user experience:

  • Implements algorithms to detect circles, lines, rectangles, and arrows
  • Integrates shape recognition into stroke building for dynamic shape generation
  • Implements a 'hold' input detection while drawing to trigger the shape recognition

Includes a .gitignore file to avoid committing build artifacts and IDE-specific files.

TODO:

  • Force a re-render after the shape recognition is triggered (I could not find how to force trigger it)
  • Implement optional user hold timeout configuration and set as an user configurable feature
  • Configure a dynamic hold threshold depending on user input (0.5 is fine for mouse, but I suppose it might be too low for stylus or touch users)

@pbsurf
Copy link
Collaborator

pbsurf commented May 4, 2025

Hi, I appreciate the PR, however, I might not merge this since it is already possible to add shapes and more using the clippings library.

Anyway, updating the dirty area for the current stroke and calling ScribbleArea::doRefresh() should re-render, e.g., holdTimer = ScribbleApp::gui->setTimer(holdTimeout, holdTimer, [this]() { replace stroke with shape... ; scribbleDoc->updateCurrStroke(scribbleDoc->strokeBuilder->getDirty()); doRefresh(); });

@Zaitam
Copy link
Author

Zaitam commented May 4, 2025

Okay so I am aware of the clippings feature, however I found it useful to be able to draw a line and hold the pen for some milliseconds (currently set to 0.7s) and the shape to be updated to a simple shape like a straight line.

The difference I find with the Clippings is the simplicity of the drawings. While I suppose clippings can get as complex as an SVG can get, the Shape Recognition would be exclusively available for Circles (Maybe ellipses too), Lines, Arrows and Rectangles.

Regarding the updating of the dirty area, I attempted triggering the updateCurrStroke and doRefresh after the shape get's modified like this:

if(scribbleDoc->strokeBuilder->shapeRecognize(event.t)) {
    // True if the shape was updated
    scribbleDoc->updateCurrStroke(scribbleDoc->strokeBuilder->getDirty());
    doRefresh();
}

However I need to trigger a movement of the camera (pan/zoom) for the figure to actually update.

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.

3 participants