Skip to content

Conversation

@saumya1317
Copy link
Contributor

Description

Closes #8

This PR implements support for plotting multiple mathematical expressions simultaneously, similar to Desmos functionality.

Changes Made

  • ✅ Created ExpressionManager class to manage multiple expressions
  • ✅ Added PlottingHelpers utility class for rendering different expression types
  • ✅ Implemented color picker for each expression
  • ✅ Added enable/disable toggle for individual expressions
  • ✅ Support for multiple expression types:
    • Cartesian: y = f(x)
    • Polar: r = f(θ)
    • Parametric: (f(t), g(t))
  • ✅ UI improvements with dedicated expression management panel
  • ✅ Auto-detection of expression types

Features

  • Users can add/remove expressions dynamically
  • Each expression has customizable color
  • Individual expressions can be enabled/disabled without removal
  • Clean UI similar to Desmos with left panel for management and right panel for plotting
  • Default color palette for new expressions

Files Changed

  • src/core/Core/Expression.hpp - Expression and ExpressionManager classes
  • src/core/Core/Expression.cpp - Implementation
  • src/core/Core/PlottingHelpers.hpp - Plotting utilities interface
  • src/core/Core/PlottingHelpers.cpp - Plotting implementation
  • src/core/Core/Application.hpp - Updated to use ExpressionManager
  • src/core/Core/Application.cpp - Updated UI and plotting logic
  • src/core/CMakeLists.txt - Added new source files

Testing

  • Multiple expressions can be added
  • Color customization works
  • Enable/disable toggle functions correctly
  • All expression types render properly
  • Expressions can be removed individually

Code of Conduct

  • I agree to follow this project's Code of Conduct

@saumya1317
Copy link
Contributor Author

@nsh07 please do check new pull request

@nsh07
Copy link
Member

nsh07 commented Oct 23, 2025

This PR looks REALLY good, the refactoring has made the code much more readable. Should I close the older PR? I think this PR contains all the changes.

@saumya1317
Copy link
Contributor Author

yeah sure !

@nsh07
Copy link
Member

nsh07 commented Oct 23, 2025

Look, I know you put time into this, but this really isn't the kind of implementation I'm looking for. I clearly mentioned in the issue that the implementation should be similar to that of how Desmos does it. Desmos is available at https://www.desmos.com/calculator

That is, there would be a button below the text field to add another text field, and you can then enter two expressions in the two text fields, and so on. Then, there would be a color selector on the left of each text field. The text fields will automatically detect the type of expression like it already does.

Please implement something like I described above. Also, avoid very extensive refactoring like the code here, you can create another issue regarding code refactoring but that is out of scope for this PR. Let me know if you want to continue in this PR or create another one.

@nsh07
Copy link
Member

nsh07 commented Oct 26, 2025

Any updates?

@saumya1317
Copy link
Contributor Author

hi almost done
image
image
is this close enough?

- Add Expression struct for managing multiple expressions with custom colors
- Implement Desmos-style collapsible sidebar with numbered slots
- Add dark top bar with Save button and branding
- Support all expression types: regular, polar, parametric, implicit, inequalities
- Add fine grid system with axis labels and zoom controls
- Fix color picker positioning to prevent overlap with text inputs
- Add /bigobj compiler flag for MSVC builds

Resolves OPCODE-Open-Spring-Fest#15
@saumya1317 saumya1317 force-pushed the feature/expression-plotting-helpers branch from 72fcfe5 to 6a5fc8b Compare October 26, 2025 17:58
@saumya1317
Copy link
Contributor Author

hii do check this new pr
@nsh07

@nsh07
Copy link
Member

nsh07 commented Oct 27, 2025

I...

You didn't have to redesign the entire app into a Desmos style UI, you just had to implement the multiple expressions in a manner (workflow, if it resolves some confusion) that is similar to Desmos. Please keep changes limited to the scope of the PR you are working on! I'm mentioning this the second time. You can create another issue for a redesign, but even then I am quite against the idea of making blatant clones of existing projects.

I am once again clearly mentioning what you have/had to do:

  • Add a button below the current expression text field that adds another text field below it, and so on
  • Add a color picker button next to each text field
  • Render the graph of each expression

All of this can be easily implemented in a simple for loop over a vector. It can be implemented in a max of 100 lines (excluding the color picker), possibly even less, just by editing one file (Application.cpp), and yet your diff for this PR is +861 -314. I am forced to not accept this PR in its current state once again because you've vastly exceeded the scope of this PR.

saumya1317 added a commit to saumya1317/ImGraph that referenced this pull request Oct 27, 2025
- Add Expression struct with text and color fields
- Add vector of expressions with dynamic add/remove
- Add color picker button next to each expression input
- Render all expressions in loop with custom colors
- Add Add Expression button below inputs
- Add /bigobj compiler flag for MSVC

Implements OPCODE-Open-Spring-Fest#15 with minimal scope changes
@saumya1317
Copy link
Contributor Author

please do check the new pr @nsh07 , also i did that intially but since you said similar to desmos so i tried to keep it close enough..

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Add support for plotting multiple expressions

2 participants