aboutsummaryrefslogtreecommitdiff
path: root/main.cpp
diff options
context:
space:
mode:
authorSamuel Fadel <samuel@nihil.ws>2023-06-06 16:58:40 +0200
committerSamuel Fadel <samuel@nihil.ws>2023-06-06 16:58:40 +0200
commit4ef37f16257b42512ec610cc5def338707308747 (patch)
treea00986754f6792a4b991a4927a9dc98f7b1919f7 /main.cpp
parent4f05d891f05a038bad7b911ce52d27e01b34f7cb (diff)
BarChart, Wayland.
* Makefile: Added some Wayland stuff to cflags/libs in pkg-config * barchart: Rendering works, no interactivity * main.cpp: Reposition some components for a more compact view * manifest.scm: glfw-wayland: Added GLFW variant with Wayland * scatterplot.cpp and voronoisplat.cpp: Cleanup
Diffstat (limited to 'main.cpp')
-rw-r--r--main.cpp59
1 files changed, 40 insertions, 19 deletions
diff --git a/main.cpp b/main.cpp
index 39aa830..b9209a8 100644
--- a/main.cpp
+++ b/main.cpp
@@ -57,7 +57,8 @@ static const int MAX_ELEMENT_MEMORY = 128 * 1024;
static const int RNG_SEED = 123;
static const int WINDOW_WIDTH = 1000;
static const int WINDOW_HEIGHT = 800;
-
+static const size_t PLOT_WIDTH = 512;
+static const size_t PLOT_HEIGHT = 512;
static const std::vector<std::string> COLORMAP_NAMES{
"Categorical",
@@ -415,6 +416,7 @@ public:
cpColormap->setColorScale(colorScaleCPs);
// bundlePlot->setColorScale(colorScaleCPs);
cpPlot->update();
+ cpBarChart->update();
}
void setRPColorScale(ColorScaleType colorScaleType) {
@@ -428,10 +430,10 @@ public:
colorScaleRPs = getColorScale(colorScaleType);
colorScaleRPs->setExtents(min, max);
- // rpBarChart->setColorScale(colorScaleRPs);
rpColormap->setColorScale(colorScaleRPs);
rpPlot->update();
splat->update();
+ rpBarChart->update();
}
// Pointers to visual components whose values are set in the main() function
@@ -655,13 +657,13 @@ int main(int argc, char *argv[])
glfwGetWindowSize(win, &width, &height);
glfwGetFramebufferSize(win, &display_width, &display_height);
- GLFWmonitor* primary = glfwGetPrimaryMonitor();
+ GLFWmonitor *primary = glfwGetPrimaryMonitor();
float xscale, yscale;
glfwGetMonitorContentScale(primary, &xscale, &yscale);
std::cout << "glfw: Detected scaling: "
<< xscale << "x" << yscale
<< std::endl;
- const GLFWvidmode * mode = glfwGetVideoMode(primary);
+ const GLFWvidmode *mode = glfwGetVideoMode(primary);
std::cout << "glfw: Detected resolution: "
<< mode->width << "x" << mode->height
<< std::endl;
@@ -721,13 +723,17 @@ int main(int argc, char *argv[])
// rpColormap.setOrientation(Colormap::Vertical);
Scatterplot cpPlot, rpPlot;
VoronoiSplat splat;
- cpPlot.setSize(512, 512);
- rpPlot.setSize(512, 512);
+ cpPlot.setSize(PLOT_WIDTH, PLOT_HEIGHT);
+ rpPlot.setSize(PLOT_WIDTH, PLOT_HEIGHT);
rpPlot.setGlyphSize(3.0f);
rpPlot.setColormap(rpColormap.texture());
- splat.setSize(512, 512);
+ splat.setSize(PLOT_WIDTH, PLOT_HEIGHT);
splat.setColormap(rpColormap.texture());
BarChart cpBarChart, rpBarChart;
+ cpBarChart.setSize(PLOT_WIDTH, 60);
+ cpBarChart.setColormap(cpColormap.texture());
+ rpBarChart.setSize(PLOT_WIDTH, 60);
+ rpBarChart.setColormap(rpColormap.texture());
m.cpPlot = &cpPlot;
m.rpPlot = &rpPlot;
m.splat = &splat;
@@ -934,11 +940,11 @@ int main(int argc, char *argv[])
// setColorData, so we just call it here
cpPlot.setColorData(v);
});
- history.rpValuesChanged.connect(
- std::bind(&VoronoiSplat::setValues, &splat, std::placeholders::_1));
history.cpValuesChanged.connect(
std::bind(&BarChart::setValues, &cpBarChart, std::placeholders::_1));
history.rpValuesChanged.connect(
+ std::bind(&VoronoiSplat::setValues, &splat, std::placeholders::_1));
+ history.rpValuesChanged.connect(
std::bind(&BarChart::setValues, &rpBarChart, std::placeholders::_1));
// ProjectionHistory takes special care of separate CP/RP selections
@@ -1006,6 +1012,8 @@ int main(int argc, char *argv[])
struct nk_image splat_img = nk_image_id((int) splat.texture());
struct nk_image cpColormap_img = nk_image_id((int) cpColormap.texture());
struct nk_image rpColormap_img = nk_image_id((int) rpColormap.texture());
+ struct nk_image cpBarChart_img = nk_image_id((int) cpBarChart.texture());
+ struct nk_image rpBarChart_img = nk_image_id((int) rpBarChart.texture());
while (!glfwWindowShouldClose(win)) {
struct nk_vec2 scale;
glfwGetWindowSize(win, &width, &height);
@@ -1114,10 +1122,15 @@ int main(int argc, char *argv[])
nk_combo_end(&ctx);
}
nk_layout_row_end(&ctx);
+
+ nk_layout_row_dynamic(&ctx, 10, 1);
+ nk_spacer(&ctx);
+ nk_layout_row_dynamic(&ctx, 10, 1);
+ nk_image(&ctx, cpColormap_img);
}
nk_end(&ctx);
- if (nk_begin(&ctx, "Regular points", nk_rect(550, 340, 350, 400),
+ if (nk_begin(&ctx, "Regular points", nk_rect(550, 340, 350, 410),
NK_WINDOW_BORDER | NK_WINDOW_TITLE)) {
ui_header(&ctx, &media, "Splat");
nk_layout_row_dynamic(&ctx, 30, 1);
@@ -1194,6 +1207,11 @@ int main(int argc, char *argv[])
nk_combo_end(&ctx);
}
nk_layout_row_end(&ctx);
+
+ nk_layout_row_dynamic(&ctx, 10, 1);
+ nk_spacer(&ctx);
+ nk_layout_row_dynamic(&ctx, 10, 1);
+ nk_image(&ctx, rpColormap_img);
}
nk_end(&ctx);
@@ -1201,14 +1219,14 @@ int main(int argc, char *argv[])
nk_style_push_color(&ctx, &s->window.background, nk_rgba(0, 0, 0, 0));
nk_style_push_style_item(&ctx, &s->window.fixed_background,
nk_style_item_color(nk_rgba(0,0,0,0)));
- if (nk_begin(&ctx, "Scatterplot", nk_rect(20, 20, splat.width(), splat.height()),
+ if (nk_begin(&ctx, "Scatterplot", nk_rect(20, 20, PLOT_WIDTH, PLOT_HEIGHT),
NK_WINDOW_NO_SCROLLBAR)) {
// Render components to their textures
splat.draw();
rpPlot.draw();
cpPlot.draw();
- nk_layout_space_begin(&ctx, NK_STATIC, splat.height(), 4);
+ nk_layout_space_begin(&ctx, NK_STATIC, PLOT_HEIGHT, 4);
struct nk_rect region = nk_layout_space_bounds(&ctx);
// Add white background rect and draw textures on top
@@ -1218,8 +1236,8 @@ int main(int argc, char *argv[])
// Rest uses custom region
region.x = region.y = 0.0f;
- region.w = static_cast<float>(splat.width());
- region.h = static_cast<float>(splat.height());
+ region.w = static_cast<float>(PLOT_WIDTH);
+ region.h = static_cast<float>(PLOT_HEIGHT);
nk_layout_space_push(&ctx, region);
nk_image(&ctx, splat_img);
nk_layout_space_push(&ctx, region);
@@ -1232,16 +1250,19 @@ int main(int argc, char *argv[])
nk_style_pop_color(&ctx);
nk_style_pop_style_item(&ctx);
- if (nk_begin(&ctx, "Colormap", nk_rect(20, 40 + splat.height(), splat.width(), 120),
+ if (nk_begin(&ctx, "Values", nk_rect(20, 40 + PLOT_HEIGHT, PLOT_WIDTH, 220),
NK_WINDOW_BORDER | NK_WINDOW_TITLE | NK_WINDOW_NO_SCROLLBAR)) {
+ cpBarChart.draw();
+ rpBarChart.draw();
+
// nk_widget(&bounds, &ctx);
ui_header(&ctx, &media, "Control points");
- nk_layout_row_dynamic(&ctx, 10, 1);
- nk_image(&ctx, cpColormap_img);
+ nk_layout_row_dynamic(&ctx, cpBarChart.height(), 1);
+ nk_image(&ctx, cpBarChart_img);
ui_header(&ctx, &media, "Regular points");
- nk_layout_row_dynamic(&ctx, 10, 1);
- nk_image(&ctx, rpColormap_img);
+ nk_layout_row_dynamic(&ctx, rpBarChart.height(), 1);
+ nk_image(&ctx, rpBarChart_img);
}
nk_end(&ctx);