-
Notifications
You must be signed in to change notification settings - Fork 56
Feat: Simplify PlotSurface API #135
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
Open
ACvanWyk
wants to merge
15
commits into
brenocq:main
Choose a base branch
from
ACvanWyk:plotsurface
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
ae10a40
Added a "simplified" PlotSurface that only takes in one array.
ACvanWyk 103ec10
fix: Get rid of unused variables
ACvanWyk 9e93356
feat: Use the `GetSurfaceValue` to get the Values for the axis depend…
ACvanWyk 3903969
feat: Add the `surface_axis` to set which axis should be used for the…
ACvanWyk 15f563e
refactor: Fix up some comments and value displayed in the combo box
ACvanWyk dc073f1
refactor: Split the new "simplified" demo into two parts
ACvanWyk 71a400a
refactor: Fix up comments + remove comments that are not applicable
ACvanWyk 35f4047
fix: Get rid of unneed case statements
ACvanWyk dff4d4f
refactor: Rename the `x_count` and `y_count` to `minor_count` and `ma…
ACvanWyk cb3b07c
refactor: Apply small optimisation to determine the `MajorRef` and `M…
ACvanWyk 62d4bcd
fix: Minor optimisation. Get rid of having to determine the major and…
ACvanWyk d4b4b25
refactor: Rename `MajorRef`, `MajorOffset`, `MinorRef` and `MinorOffs…
ACvanWyk 77ac908
feat: Update the surface plot API based on initial feedback
ACvanWyk c4faa99
refactor: Change x and y count to minor and major count and add some …
ACvanWyk 39fab8d
fix: Make the `ImPlot3DSurfaceFlags_PlaneXY` the default
ACvanWyk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,8 @@ | |
#include "imgui.h" | ||
#ifndef IMGUI_DISABLE | ||
|
||
#include <limits.h> | ||
|
||
//----------------------------------------------------------------------------- | ||
// [SECTION] Macros and Defines | ||
//----------------------------------------------------------------------------- | ||
|
@@ -50,6 +52,7 @@ | |
#define IMPLOT3D_AUTO -1 // Deduce variable automatically | ||
#define IMPLOT3D_AUTO_COL ImVec4(0, 0, 0, -1) // Deduce color automatically | ||
#define IMPLOT3D_TMP template <typename T> IMPLOT3D_API | ||
#define IMPLOT3D_DEFAULT_MAJOR_STRIDE INT_MAX | ||
|
||
//----------------------------------------------------------------------------- | ||
// [SECTION] Forward declarations and basic types | ||
|
@@ -226,6 +229,13 @@ enum ImPlot3DSurfaceFlags_ { | |
ImPlot3DSurfaceFlags_NoLines = 1 << 10, // No lines will be rendered | ||
ImPlot3DSurfaceFlags_NoFill = 1 << 11, // No fill will be rendered | ||
ImPlot3DSurfaceFlags_NoMarkers = 1 << 12, // No markers will be rendered | ||
|
||
// The plane to use for the surface plot | ||
ImPlot3DSurfaceFlags_PlaneXY = 0, // Use the XY plane and Z values for surface. Default behavior. Use for None flag | ||
ImPlot3DSurfaceFlags_PlaneXZ = 1 << 13, // Use the XZ plane and Y values for surface | ||
ImPlot3DSurfaceFlags_PlaneYZ = 1 << 14, // Use the YZ plane and X values for surface | ||
ImPlot3DSurfaceFlags_SwapAxes = 1 << 15, // Swap the minor and major axis. Only has an effect on the PlotSurface function where only the values are passed in | ||
ImPlot3DSurfaceFlags_PlaneMask_ = ImPlot3DSurfaceFlags_PlaneXY | ImPlot3DSurfaceFlags_PlaneXZ | ImPlot3DSurfaceFlags_PlaneYZ, | ||
}; | ||
|
||
// Flags for PlotMesh | ||
|
@@ -451,8 +461,11 @@ IMPLOT3D_TMP void PlotQuad(const char* label_id, const T* xs, const T* ys, const | |
// Plot the surface defined by a grid of vertices. The grid is defined by the x and y arrays, and the z array contains the height of each vertex. A | ||
// total of x_count * y_count vertices are expected for each array. Leave #scale_min and #scale_max both at 0 for automatic color scaling, or set them | ||
// to a predefined range | ||
IMPLOT3D_TMP void PlotSurface(const char* label_id, const T* xs, const T* ys, const T* zs, int x_count, int y_count, double scale_min = 0.0, | ||
IMPLOT3D_TMP void PlotSurface(const char* label_id, const T* xs, const T* ys, const T* zs, int minor_count, int major_count, double scale_min = 0.0, | ||
double scale_max = 0.0, ImPlot3DSurfaceFlags flags = 0, int offset = 0, int stride = sizeof(T)); | ||
IMPLOT3D_TMP void PlotSurface(const char* label_id, const T* values, int minor_count, int major_count, double scale_min = 0.0, double scale_max = 0.0, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could maybe simplify this. Having all these parameters allows for a lot of control. |
||
ImPlot3DSurfaceFlags flags = 0, const ImVec2& minor_bounds = ImVec2(-1, 1), const ImVec2& major_bounds = ImVec2(-1, 1), | ||
int offset = 0, int stride = sizeof(T), int major_offset = 0, int major_stride = IMPLOT3D_DEFAULT_MAJOR_STRIDE); | ||
|
||
IMPLOT3D_API void PlotMesh(const char* label_id, const ImPlot3DPoint* vtx, const unsigned int* idx, int vtx_count, int idx_count, | ||
ImPlot3DMeshFlags flags = 0); | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need this for
INT_MAX
used inIMPLOT3D_DEFAULT_MAJOR_STRIDE
. Cannot usesizeof(T)
,-1(i/uint8)
or0
which are all potentially valid values.I cannot think of a good value to make
IMPLOT3D_DEFAULT_MAJOR_STRIDE
other thanINT_MAX
. Maybe somebody has a better suggestion?