Skip to content

Commit

Permalink
version display tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
wkjarosz committed Dec 5, 2023
1 parent 78e2c68 commit 35ceea9
Show file tree
Hide file tree
Showing 31 changed files with 226 additions and 83 deletions.
57 changes: 33 additions & 24 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,29 @@ cmake_minimum_required(VERSION 3.13)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/" "${CMAKE_SOURCE_DIR}/resources")

include(VersionFromGit)

string(TIMESTAMP BUILD_TIME "%Y-%m-%d %H:%M")
message(STATUS "Saving build timestamp: ${BUILD_TIME}")

version_from_git(LOG ON TIMESTAMP "%Y-%m-%d-%H:%M:%S")

project(
SamplinSafari
DESCRIPTION
"A research tool to visualize and interactively inspect high-dimensional (quasi) Monte Carlo samplers."
VERSION 2.0.0
VERSION ${SEMVER}
LANGUAGES C CXX
)

if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(APP_BITS_VERSION "64 bit")
set(VERSION_LONG "${SEMVER} (64 bit)")
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(APP_BITS_VERSION "32 bit")
set(VERSION_LONG "${SEMVER} (32 bit)")
endif()

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/common.cpp.in ${CMAKE_CURRENT_BINARY_DIR}/src/common.cpp @ONLY)

include(sanitizers)

# Set ourselves as the startup project in visual studio. Not available until cmake 3.6, but doesn't break older
Expand Down Expand Up @@ -194,22 +200,22 @@ add_library(samplerlib OBJECT STATIC
include/sampler/Random.h
include/sampler/RandomPermutation.h
include/sampler/Sobol.h
src/Misc.cpp
src/Halton.cpp
src/Jittered.cpp
src/LP.cpp
src/MultiJittered.cpp
src/NRooks.cpp
src/OA.cpp
src/OAAddelmanKempthorne.cpp
src/OABose.cpp
src/OABoseBush.cpp
src/OABush.cpp
src/OACMJND.cpp
src/SOA.cpp
src/Random.cpp
src/Sobol.cpp
src/SobolMatrices.cpp)
src/sampler/Misc.cpp
src/sampler/Halton.cpp
src/sampler/Jittered.cpp
src/sampler/LP.cpp
src/sampler/MultiJittered.cpp
src/sampler/NRooks.cpp
src/sampler/OA.cpp
src/sampler/OAAddelmanKempthorne.cpp
src/sampler/OABose.cpp
src/sampler/OABoseBush.cpp
src/sampler/OABush.cpp
src/sampler/OACMJND.cpp
src/sampler/SOA.cpp
src/sampler/Random.cpp
src/sampler/Sobol.cpp
src/sampler/SobolMatrices.cpp)

# Link dependencies
target_link_libraries(
Expand All @@ -229,14 +235,17 @@ set(HELLO_IMGUI_ICON_DISPLAY_NAME ${output_name})
set(HELLO_IMGUI_BUNDLE_NAME ${output_name})
set(HELLO_IMGUI_BUNDLE_COPYRIGHT "© Wojciech Jarosz, ${YEAR}")
set(HELLO_IMGUI_BUNDLE_EXECUTABLE ${output_name})
set(HELLO_IMGUI_BUNDLE_VERSION ${APP_BITS_VERSION})
set(HELLO_IMGUI_BUNDLE_SHORT_VERSION ${PROJECT_VERSION})
set(HELLO_IMGUI_BUNDLE_VERSION ${SEMVER})
set(HELLO_IMGUI_BUNDLE_SHORT_VERSION ${SEMVER})
set(HELLO_IMGUI_BUNDLE_ICON_FILE icon.icns)

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/shell.emscripten.html.in ${CMAKE_CURRENT_SOURCE_DIR}/shell.emscripten.html @ONLY)

hello_imgui_add_app(SamplinSafari
gui/app.cpp
gui/shader.cpp
gui/export_to_file.cpp
src/app.cpp
${CMAKE_CURRENT_BINARY_DIR}/src/common.cpp
src/shader.cpp
src/export_to_file.cpp
)

set_target_properties(SamplinSafari PROPERTIES
Expand Down
13 changes: 10 additions & 3 deletions cmake/VersionFromGit.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,10 @@ function( version_from_git )
ERROR_STRIP_TRAILING_WHITESPACE
)
if( NOT git_result EQUAL 0 )
message( FATAL_ERROR
message( WARNING
"[VersionFromGit] Failed to execute Git: ${git_error}"
)
set( git_describe "" )
endif()

# Get Git tag
Expand All @@ -78,9 +79,10 @@ function( version_from_git )
ERROR_STRIP_TRAILING_WHITESPACE
)
if( NOT git_result EQUAL 0 )
message( FATAL_ERROR
message( WARNING
"[VersionFromGit] Failed to execute Git: ${git_error}"
)
set( git_tag "" )
endif()

if( git_tag MATCHES "^v(0|[1-9][0-9]*)[.](0|[1-9][0-9]*)[.](0|[1-9][0-9]*)(-[.0-9A-Za-z-]+)?([+][.0-9A-Za-z-]+)?$" )
Expand All @@ -90,9 +92,14 @@ function( version_from_git )
set( identifiers "${CMAKE_MATCH_4}" )
set( metadata "${CMAKE_MATCH_5}" )
else()
message( FATAL_ERROR
message( WARNING
"[VersionFromGit] Git tag isn't valid semantic version: [${git_tag}]"
)
set( version_major "0" )
set( version_minor "0" )
set( version_patch "0" )
set( identifiers "" )
set( metadata "" )
endif()

if( "${git_tag}" STREQUAL "${git_describe}" )
Expand Down
5 changes: 4 additions & 1 deletion gui/app.h → include/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#pragma once

#include "common.h"
#include "linalg.h"
using namespace linalg::aliases;

Expand Down Expand Up @@ -34,8 +35,8 @@ using namespace linalg::aliases;
}

#include "arcball.h"
// #include "gui_app.h"
#include "hello_imgui/hello_imgui.h"
#include "misc/cpp/imgui_stdlib.h"
#include "shader.h"
#include <galois++/array2d.h>
#include <map>
Expand Down Expand Up @@ -108,6 +109,7 @@ class SampleViewer
void update_GPU_grids();
void set_view(CameraType view);
void draw_editor();
void draw_about_dialog();
void process_hotkeys();
void populate_point_subset();
void generate_grid(vector<float3> &positions, int gridRes);
Expand Down Expand Up @@ -155,6 +157,7 @@ class SampleViewer

float m_time1 = 0.f, m_time2 = 0.f;
float3 m_point_color = {0.9f, 0.55f, 0.1f};
float3 m_bg_color = {0.0f, 0.0f, 0.0f};
HelloImGui::RunnerParams m_params;

bool m_idling_backup = false;
Expand Down
File renamed without changes.
28 changes: 28 additions & 0 deletions include/common.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//
// Copyright (C) Wojciech Jarosz <[email protected]>. All rights reserved.
// Use of this source code is governed by a BSD-style license that can
// be found in the LICENSE.txt file.
//

#pragma once

#if defined(_MSC_VER)
// Make MS cmath define M_PI but not the min/max macros
#define _USE_MATH_DEFINES
#define NOMINMAX
#endif

#include <string>

std::vector<std::string> split(std::string text, const std::string &delim);
std::string to_lower(std::string str);
std::string to_upper(std::string str);

int version_major();
int version_minor();
int version_patch();
std::string version();
std::string git_hash();
std::string git_describe();
std::string build_timestamp();
std::string backend();
File renamed without changes.
36 changes: 36 additions & 0 deletions include/imgui_ext.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include "imgui.h"

namespace ImGui
{

inline bool ToggleButton(const char *label, bool *active)
{
ImGui::PushStyleColor(ImGuiCol_Button, *active ? GetColorU32(ImGuiCol_ButtonActive) : GetColorU32(ImGuiCol_Button));
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, GetColorU32(ImGuiCol_FrameBgHovered));
ImGui::PushStyleColor(ImGuiCol_ButtonActive, GetColorU32(ImGuiCol_FrameBgActive));

bool ret;
if ((ret = ImGui::Button(label)))
*active = !*active;
ImGui::PopStyleColor(3);
return ret;
}

inline void Text(const string &text)
{
return TextUnformatted(text.c_str());
}

// return true when activated.
inline bool MenuItem(const string &label, const string &shortcut = "", bool selected = false, bool enabled = true)
{
return MenuItem(label.c_str(), shortcut.c_str(), selected, enabled);
}

// return true when activated + toggle (*p_selected) if p_selected != NULL
inline bool MenuItem(const string &label, const string &shortcut, bool *p_selected, bool enabled = true)
{
return MenuItem(label.c_str(), shortcut.c_str(), p_selected, enabled);
}

} // namespace ImGui
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion shell.emscripten.html → shell.emscripten.html.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta charset="utf-8" />
<meta content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no"
name="viewport" />
<title>Samplin Safari2</title>
<title>@HELLO_IMGUI_ICON_DISPLAY_NAME@</title>
<style>
body {
margin: 0;
Expand Down
Loading

0 comments on commit 35ceea9

Please sign in to comment.