(wip): combobox for transfer function
This commit is contained in:
parent
db1b1a60ca
commit
5ccc9b0fe2
|
|
@ -4,8 +4,7 @@
|
|||
|
||||
First, initialize the imGui submodule:
|
||||
```bash
|
||||
git submodule init imgui
|
||||
git submodule update imgui
|
||||
git submodule update --init
|
||||
```
|
||||
|
||||
Then, compile using cmake:
|
||||
|
|
|
|||
|
|
@ -51,3 +51,4 @@ void copyConstantsToDevice() {
|
|||
__device__ float d_opacityK;
|
||||
__device__ float d_sigmoidOne;
|
||||
__device__ float d_sigmoidTwo;
|
||||
__device__ int d_tfComboSelected;
|
||||
|
|
|
|||
|
|
@ -63,6 +63,8 @@ extern __device__ float d_opacityK;
|
|||
// sigmoid function variables
|
||||
extern __device__ float d_sigmoidOne;
|
||||
extern __device__ float d_sigmoidTwo;
|
||||
// combo box index
|
||||
extern __device__ int d_tfComboSelected;
|
||||
|
||||
const int lenStopsPythonLike = 5;
|
||||
const int lenStopsGrayscale = 2;
|
||||
|
|
|
|||
|
|
@ -29,9 +29,12 @@ Widget::Widget(GLFWwindow* window) {
|
|||
this->opacityK = 0;
|
||||
this->sigmoidOne = 0.5f;
|
||||
this->sigmoidTwo = -250.0f;
|
||||
this->tfComboSelected = 0;
|
||||
};
|
||||
|
||||
// TODO: can be marginally improvement by only copying changed values to device - however we're dealing with individual floats here so i dont think the benefit would be all that obvious.
|
||||
// REFACTOR: should probably not have all the logic in one function; something like a list of ImplementedWidgets with each a Render() function (a la interface) would be better.
|
||||
// TODO: can be marginally improved by only copying changed values to device - however we're dealing with individual floats here so i dont think the benefit would be all that obvious.
|
||||
// TODO: wrap basically all ImGui calls in if statements; better form + allows for checking return values / errors.
|
||||
void Widget::tick(double fps) {
|
||||
if (this->renderOnce) {
|
||||
this->renderOnce = false;
|
||||
|
|
@ -49,6 +52,23 @@ void Widget::tick(double fps) {
|
|||
ImGui::DragInt("k (log [1e-10, 1])", &this->opacityK, 1, 0, 100, "%d%%", ImGuiSliderFlags_AlwaysClamp);
|
||||
ImGui::DragFloat("sigmoidOne", &this->sigmoidOne, 0.01f, 0.0f, 1.0f, "%.2f");
|
||||
ImGui::InputFloat("sigmoidTwo", &this->sigmoidTwo, 10.0f, 100.0f, "%.0f");
|
||||
|
||||
// the items[] contains the entries for the combobox. The selected index is stored as an int on this->tfComboSelected
|
||||
// the default entry is set in the constructor, so if you want that to be a specific entry just change it
|
||||
// whatever value is selected here is available on the gpu as d_tfComboSelected.
|
||||
const char* items[] = {"First option", "Another option", "this is the third option", "..."};
|
||||
if (ImGui::BeginCombo("ComboBox for transferFunction", items[this->tfComboSelected]))
|
||||
{
|
||||
for (int n = 0; n < IM_ARRAYSIZE(items); n++)
|
||||
{
|
||||
const bool is_selected = (this->tfComboSelected == n);
|
||||
if (ImGui::Selectable(items[n], is_selected))
|
||||
this->tfComboSelected = n;
|
||||
if (is_selected)
|
||||
ImGui::SetItemDefaultFocus();
|
||||
}
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
ImGui::End();
|
||||
|
||||
ImGui::Begin("Light Controls");
|
||||
|
|
@ -97,6 +117,7 @@ void Widget::copyToDevice() {
|
|||
|
||||
cudaMemcpyToSymbol(&d_sigmoidOne, &this->sigmoidOne, sizeof(float));
|
||||
cudaMemcpyToSymbol(&d_sigmoidTwo, &this->sigmoidTwo, sizeof(float));
|
||||
cudaMemcpyToSymbol(&d_tfComboSelected, &this->tfComboSelected, sizeof(float));
|
||||
}
|
||||
|
||||
Widget::~Widget() {
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ public:
|
|||
bool renderOnce;
|
||||
char* fps;
|
||||
|
||||
int tfComboSelected;
|
||||
int opacityK;
|
||||
float opacityKReal;
|
||||
float sigmoidOne;
|
||||
|
|
|
|||
Loading…
Reference in New Issue