Skip to content
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

Move coloring info logic into a dedicated handler #1672

Merged
merged 26 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion application/testing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ f3d_test(NAME TestVolumeMag DATA vase_4comp.vti ARGS -vb LONG_TIMEOUT)
f3d_test(NAME TestVolumeComp DATA vase_4comp.vti ARGS -vb --comp=3 LONG_TIMEOUT)
f3d_test(NAME TestVolumeDirect DATA vase_4comp.vti ARGS -vb --comp=-2 LONG_TIMEOUT)
f3d_test(NAME TestVolumeCells DATA waveletArrays.vti ARGS -vb --cells LONG_TIMEOUT)
f3d_test(NAME TestVolumeNonScalars DATA waveletArrays.vti ARGS -vb -s --coloring-array=RandomPointScalars LONG_TIMEOUT)
f3d_test(NAME TestVolumeColoringArray DATA waveletArrays.vti ARGS -vb --coloring-array=Result LONG_TIMEOUT)
f3d_test(NAME TestTextureNormal DATA WaterBottle.glb ARGS --texture-normal=${F3D_SOURCE_DIR}/testing/data/normal.png --normal-scale=0.1)
f3d_test(NAME TestTextureMaterial DATA WaterBottle.glb ARGS --texture-material=${F3D_SOURCE_DIR}/testing/data/red_mod.jpg --roughness=1 --metallic=1)
f3d_test(NAME TestTextureMaterialWithOptions DATA WaterBottle.glb ARGS --texture-material=${F3D_SOURCE_DIR}/testing/data/red_mod.jpg --roughness=0.5 --metallic=0.5)
Expand Down Expand Up @@ -221,6 +221,7 @@ f3d_test(NAME TestMultiFileColoring DATA mb/recursive ARGS --multi-file-mode=all
f3d_test(NAME TestMultiFileVolume DATA multi ARGS --multi-file-mode=all -vsb --coloring-array=Scalars_)
f3d_test(NAME TestMultiFileColoringTexture DATA mb/recursive/mb_1_0.vtp mb/recursive/mb_2_0.vtp world.obj ARGS --multi-file-mode=all -sb --coloring-array=Normals --comp=1)
f3d_test(NAME TestMultiFilePositionals DATA mb/recursive/mb_0_0.vtu mb/recursive/mb_1_0.vtp ARGS --multi-file-mode=all -s --coloring-array=Polynomial -b)
f3d_test(NAME TestMultiFileNonCoherentComponentNames DATA bluntfin.vts bluntfin_t.vtu ARGS --multi-file-mode=all --scalar-coloring --coloring-array=Momentum --comp=2 --bar)
f3d_test(NAME TestMultiInputArg ARGS --input ${F3D_SOURCE_DIR}/testing/data/mb/recursive/mb_0_0.vtu ${F3D_SOURCE_DIR}/testing/data/mb/recursive/mb_1_0.vtp --multi-file-mode=all -s --coloring-array=Polynomial -b)
f3d_test(NAME TestMultiInputMultiArgs ARGS --input ${F3D_SOURCE_DIR}/testing/data/mb/recursive/mb_0_0.vtu --input ${F3D_SOURCE_DIR}/testing/data/mb/recursive/mb_1_0.vtp --multi-file-mode=all -s --coloring-array=Polynomial -b)
f3d_test(NAME TestInvalidUpDirection DATA suzanne.ply ARGS -g --up=W REGEXP "W is not a valid up direction" NO_BASELINE)
Expand Down Expand Up @@ -753,6 +754,8 @@ f3d_test(NAME TestInteractionCycleCell DATA waveletArrays.vti INTERACTION) #VCCC
f3d_test(NAME TestInteractionCycleComp DATA dragon.vtu INTERACTION) #SYYYY
f3d_test(NAME TestInteractionCycleScalars DATA dragon.vtu INTERACTION) #BSSSS
f3d_test(NAME TestInteractionCycleCellInvalidIndex DATA waveletArrays.vti INTERACTION) #SSC
f3d_test(NAME TestInteractionVolumeCycle DATA waveletArrays.vti ARGS INTERACTION) #VSS
f3d_test(NAME TestInteractionVolumeAfterColoring DATA waveletArrays.vti ARGS INTERACTION) #SSSV
f3d_test(NAME TestInteractionVolumeInverse DATA HeadMRVolume.mhd ARGS --camera-position=127.5,-400,127.5 --camera-view-up=0,0,1 INTERACTION) #VI
f3d_test(NAME TestInteractionMultiFileVolume DATA multi ARGS --multi-file-mode=all INTERACTION) #SSVB
f3d_test(NAME TestInteractionPointCloud DATA pointsCloud.vtp ARGS --point-sprites-size=20 INTERACTION) #O
Expand Down Expand Up @@ -863,6 +866,9 @@ f3d_test(NAME TestVerboseWrongArray DATA dragon.vtu ARGS -s --coloring-array=dum
# Default scalar array verbosity test
f3d_test(NAME TestVerboseDefaultScalar DATA HeadMRVolume.mhd ARGS -s --verbose REGEXP "Coloring using point array named MetaImage, Magnitude" NO_BASELINE)

# Volume array verbosity test
f3d_test(NAME TestVerboseVolume DATA HeadMRVolume.mhd ARGS -v --verbose REGEXP "Coloring using point array named MetaImage .forced., Magnitude" NO_BASELINE)

# Incorrect component test
f3d_test(NAME TestIncorrectComponent DATA dragon.vtu ARGS -s --comp=4 REGEXP "Invalid component index: 4" NO_BASELINE)

Expand Down Expand Up @@ -997,6 +1003,9 @@ f3d_test(NAME TestVersion ARGS --version REGEXP "Version:")
# Test readers-list display
f3d_test(NAME TestReadersList ARGS --readers-list REGEXP_FAIL "No registered reader found")

# Test invalid component string coverage
f3d_test(NAME TestInteractionInvalidComponent INTERACTION DATA cow.vtp ARGS --comp=1 NO_BASELINE) #H

# Test multi plugin readers-lists
if(F3D_PLUGIN_BUILD_ALEMBIC AND F3D_PLUGIN_BUILD_ASSIMP)
f3d_test(NAME TestReadersListMultiplePlugins ARGS --readers-list --load-plugins=assimp,alembic NO_BASELINE REGEXP_FAIL "Plugin failed to load")
Expand Down
2 changes: 1 addition & 1 deletion doc/libf3d/OPTIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ model.scivis.range|vector\<double\><br>optional<br>render|Set the *coloring rang
model.point_sprites.enable|bool<br>false<br>render|Show sphere *points sprites* instead of the geometry.|\-\-point-sprites
model.point_sprites.type|string<br>sphere<br>render|Set the sprites type when showing point sprites (can be `sphere` or `gaussian`).|\-\-point-stripes-type
model.point_sprites.size|double<br>10.0<br>render|Set the *size* of point sprites.|\-\-point-stripes-size
model.volume.enable|bool<br>false<br>render|Enable *volume rendering*. It is only available for 3D image data (vti, dcm, nrrd, mhd files) and will display nothing with other formats.|\-\-volume
model.volume.enable|bool<br>false<br>render|Enable *volume rendering*. It is only available for 3D image data (vti, dcm, nrrd, mhd files) and will display nothing with other formats. It forces coloring.|\-\-volume
model.volume.inverse|bool<br>false<br>render|Inverse the linear opacity function.|\-\-inverse

## Render Options
Expand Down
2 changes: 1 addition & 1 deletion doc/user/INTERACTIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Other options can be toggled directly by pressing the following hotkeys:

* <kbd>W</kbd>: cycle animations.
* <kbd>B</kbd>: display of the scalar bar, only when coloring and not using direct scalars.
* <kbd>V</kbd>: volume rendering.
* <kbd>V</kbd>: volume rendering, forces coloring.
* <kbd>I</kbd>: opacity function inversion during volume rendering.
* <kbd>O</kbd>: point sprites rendering.
* <kbd>P</kbd>: translucency support.
Expand Down
2 changes: 1 addition & 1 deletion doc/user/OPTIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ Options|Default|Description
-b, \-\-bar||Show *scalar bar* of the coloring by array.<br>Use with the scalar option.
\-\-colormap\-file=\<name\>||Set a *colormap file for the coloring*.<br>See [color maps](COLOR_MAPS.md).<br>Use with the scalar option.
\-\-colormap=\<color_list\>||Set a *custom colormap for the coloring*.<br>This is a list of colors in the format `val1,red1,green1,blue1,...,valN,redN,greenN,blueN`<br>where all values are in the range (0,1).<br>Ignored if `--colormap-file` option is specified.<br>Use with the scalar option.
-v, \-\-volume||Enable *volume rendering*. It is only available for 3D image data (vti, dcm, nrrd, mhd files) and will display nothing with other formats.
-v, \-\-volume||Enable *volume rendering*. It is only available for 3D image data (vti, dcm, nrrd, mhd files) and will display nothing with other formats. It forces coloring.
-i, \-\-inverse||Inverse the linear opacity function used for volume rendering.

## Camera configuration options
Expand Down
26 changes: 16 additions & 10 deletions library/src/interactor_impl.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ class interactor_impl::internals
vtkRenderWindow* renWin = self->Window.GetRenderWindow();
vtkF3DRenderer* ren = vtkF3DRenderer::SafeDownCast(renWin->GetRenderers()->GetFirstRenderer());
bool checkColoring = false;
bool printColoring = false;
bool render = false;

// Available keycodes: None
Expand All @@ -190,28 +191,28 @@ class interactor_impl::internals
case 'C':
if (ren)
{
ren->CycleScalars(vtkF3DRenderer::CycleType::FIELD);
self->Window.PrintColoringDescription(log::VerboseLevel::DEBUG);
ren->CycleFieldForColoring();
checkColoring = true;
render = true;
printColoring = true;
}
break;
case 'S':
if (ren)
{
ren->CycleScalars(vtkF3DRenderer::CycleType::ARRAY_INDEX);
self->Window.PrintColoringDescription(log::VerboseLevel::DEBUG);
ren->CycleArrayForColoring();
checkColoring = true;
render = true;
printColoring = true;
}
break;
case 'Y':
if (ren)
{
ren->CycleScalars(vtkF3DRenderer::CycleType::COMPONENT);
self->Window.PrintColoringDescription(log::VerboseLevel::DEBUG);
ren->CycleComponentForColoring();
checkColoring = true;
render = true;
printColoring = true;
}
break;
case 'B':
Expand Down Expand Up @@ -273,6 +274,7 @@ class interactor_impl::internals
case 'V':
self->Options.model.volume.enable = !self->Options.model.volume.enable;
render = true;
printColoring = true;
break;
case 'I':
self->Options.model.volume.inverse = !self->Options.model.volume.inverse;
Expand Down Expand Up @@ -379,15 +381,19 @@ class interactor_impl::internals
if (checkColoring)
{
// Resynchronise renderer coloring status with options
self->Options.model.scivis.enable = ren->GetColoringEnabled();
self->Options.model.scivis.cells = ren->GetColoringUseCell();
self->Options.model.scivis.array_name = ren->GetColoringArrayName();
self->Options.model.scivis.component = ren->GetColoringComponent();
self->Options.model.scivis.enable = ren->GetEnableColoring();
self->Options.model.scivis.cells = ren->GetUseCellColoring();
self->Options.model.scivis.array_name = ren->GetArrayNameForColoring();
self->Options.model.scivis.component = ren->GetComponentForColoring();
}
if (render)
{
self->Window.render();
}
if (printColoring)
{
self->Window.PrintColoringDescription(log::VerboseLevel::DEBUG);
}
}

static void OnDropFiles(vtkObject*, unsigned long, void* clientData, void* callData)
Expand Down
7 changes: 5 additions & 2 deletions library/src/window_impl.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -533,8 +533,11 @@ void window_impl::UpdateDynamicOptions()
renderer->SetNormalScale(opt.model.normal.scale);
renderer->SetTextureMatCap(opt.model.matcap.texture);

renderer->SetColoring(opt.model.scivis.enable, opt.model.scivis.cells,
opt.model.scivis.array_name, opt.model.scivis.component);
renderer->SetEnableColoring(opt.model.scivis.enable);
renderer->SetUseCellColoring(opt.model.scivis.cells);
renderer->SetArrayNameForColoring(opt.model.scivis.array_name);
renderer->SetComponentForColoring(opt.model.scivis.component);

renderer->SetScalarBarRange(opt.model.scivis.range);
renderer->SetColormap(opt.model.scivis.colormap);
renderer->ShowScalarBar(opt.ui.scalar_bar);
Expand Down
3 changes: 3 additions & 0 deletions testing/baselines/TestInteractionVolumeAfterColoring.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions testing/baselines/TestInteractionVolumeCycle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions testing/baselines/TestMultiFileNonCoherentComponentNames.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions testing/baselines/TestVolumeColoringArray.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 0 additions & 3 deletions testing/baselines/TestVolumeNonScalars.png

This file was deleted.

10 changes: 10 additions & 0 deletions testing/recordings/TestInteractionInvalidComponent.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# StreamVersion 1.2
ExposeEvent 0 599 0 0 0 0 0
RenderEvent 0 599 0 0 0 0 0
TimerEvent 0 599 0 0 0 0 0
TimerEvent 0 599 0 0 0 0 0
KeyPressEvent 291 357 0 104 1 h 0
CharEvent 291 357 0 104 1 h 0
TimerEvent 0 599 0 0 0 0 0
KeyReleaseEvent 291 357 0 104 1 h 0
TimerEvent 291 357 0 104 1 h 0
28 changes: 28 additions & 0 deletions testing/recordings/TestInteractionVolumeAfterColoring.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# StreamVersion 1.2
ExposeEvent 0 599 0 0 0 0 0
RenderEvent 0 599 0 0 0 0 0
TimerEvent 0 599 0 0 0 0 0
KeyPressEvent 1394 -281 0 115 1 s 0
CharEvent 1394 -281 0 115 1 s 0
TimerEvent 1394 -281 0 115 1 s 0
KeyReleaseEvent 1394 -281 0 115 1 s 0
TimerEvent 1394 -281 0 115 1 s 0
TimerEvent 1394 -281 0 115 1 s 0
KeyPressEvent 1394 -281 0 115 1 s 0
CharEvent 1394 -281 0 115 1 s 0
TimerEvent 1394 -281 0 115 1 s 0
KeyReleaseEvent 1394 -281 0 115 1 s 0
TimerEvent 1394 -281 0 115 1 s 0
TimerEvent 1394 -281 0 115 1 s 0
KeyPressEvent 1394 -281 0 115 1 s 0
CharEvent 1394 -281 0 115 1 s 0
TimerEvent 1394 -281 0 115 1 s 0
KeyReleaseEvent 1394 -281 0 115 1 s 0
TimerEvent 1394 -281 0 115 1 s 0
TimerEvent 1394 -281 0 115 1 s 0
KeyPressEvent 1394 -281 0 118 1 v 0
CharEvent 1394 -281 0 118 1 v 0
TimerEvent 1394 -281 0 118 1 v 0
KeyReleaseEvent 1394 -281 0 118 1 v 0
TimerEvent 1394 -281 0 118 1 v 0
TimerEvent 1394 -281 0 118 1 v 0
23 changes: 23 additions & 0 deletions testing/recordings/TestInteractionVolumeCycle.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# StreamVersion 1.2
ExposeEvent 0 599 0 0 0 0 0
RenderEvent 0 599 0 0 0 0 0
TimerEvent 0 599 0 0 0 0 0
TimerEvent 0 599 0 0 0 0 0
TimerEvent 363 259 0 0 0 0 0
KeyPressEvent 363 259 0 118 1 v 0
CharEvent 363 259 0 118 1 v 0
TimerEvent 363 259 0 118 1 v 0
KeyReleaseEvent 363 259 0 118 1 v 0
TimerEvent 363 259 0 118 1 v 0
TimerEvent 363 259 0 118 1 v 0
KeyPressEvent 363 259 0 115 1 s 0
CharEvent 363 259 0 115 1 s 0
TimerEvent 363 259 0 115 1 s 0
KeyReleaseEvent 363 259 0 115 1 s 0
TimerEvent 363 259 0 115 1 s 0
TimerEvent 363 259 0 115 1 s 0
KeyPressEvent 363 259 0 115 1 s 0
CharEvent 363 259 0 115 1 s 0
TimerEvent 363 259 0 115 1 s 0
KeyReleaseEvent 363 259 0 115 1 s 0
TimerEvent 363 259 0 115 1 s 0
1 change: 1 addition & 0 deletions vtkext/private/module/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ endforeach()

set(classes
F3DLog
F3DColoringInfoHandler
vtkF3DCachedLUTTexture
vtkF3DCachedSpecularTexture
vtkF3DConsoleOutputWindow
Expand Down
Loading