Skip to content

Backport S-Rep support updates #65

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

Draft
wants to merge 21 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
1ef7a30
ENH: Allow import .xml file to visualize S-Rep
yehan0223 Apr 19, 2021
8c4e999
ENH: Visualize spokes and assign point data for coloring
yehan0223 Apr 21, 2021
415fc21
ENH: Load customized colormap when reading SReps
yehan0223 Apr 21, 2021
472c234
ENH: Allow SPV to Load SReps from CLI
yehan0223 Apr 22, 2021
410d271
ENH: Allow reading s-rep from csv files
yehan0223 Jun 23, 2021
79b5bf2
ENH: Update to support new .srep.json files
Mar 4, 2022
fe97b59
ENH: Allow SPV to read .fcsv fiducial files
yehan0223 Sep 10, 2021
d3923d4
ENH: Change Import layout to vertical to reduce module area
yehan0223 Nov 22, 2023
4d1a024
BUG: Fix filename info for fiducial
yehan0223 Nov 22, 2023
488f43a
STYLE: Rearrange ui layout
yehan0223 Mar 25, 2024
03461f0
ENH: make csv loader accept new s-rep format
yehan0223 Mar 25, 2024
b1d8aa7
ENH: Intial commit for visualizing time series data
yehan0223 Mar 25, 2024
e5c8ca3
ENH: timeSeriesLoader visualizes first frames
yehan0223 Mar 26, 2024
456890d
ENH: connect time series slider signals
yehan0223 Mar 26, 2024
457ec66
ENH: Add initial time series visualization functionality.
yehan0223 Mar 29, 2024
683688f
ENH: Set slider widget on load/delete time series
yehan0223 Apr 8, 2024
61ba3b5
ENH: Sync slider, check time steps on loading time series
yehan0223 Apr 8, 2024
721d7b9
ENH: keep attribute and colormap when changing time index
yehan0223 May 15, 2024
4c72a8f
ENH: align shapes and keep cam config when loading/changing time index
yehan0223 May 20, 2024
84a7555
ENH: Add play button actions
yehan0223 Jun 26, 2024
6c7a315
BUG: Reset view at each time step.
yehan0223 Nov 4, 2024
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
7 changes: 7 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ set(CXX_FILES
backgroundDialogQT.cxx
cameraDialogQT.cxx
CSVloaderQT.cxx
timeSeriesLoaderQT.cxx
customizeColorMapByDirectionDialogQT.cxx
gradientArrow.cxx
gradientWidgetQT.cxx
Expand All @@ -38,6 +39,7 @@ set(UI_FILES
backgroundDialogQT.ui
cameraDialogQT.ui
CSVloaderQT.ui
timeSeriesLoaderQT.ui
customizeColorMapByDirectionDialogQT.ui
ShapePopulationMainWindowQT.ui
ShapePopulationQT.ui
Expand All @@ -47,6 +49,7 @@ set(QT_WRAP
backgroundDialogQT.h
cameraDialogQT.h
CSVloaderQT.h
timeSeriesLoaderQT.h
customizeColorMapByDirectionDialogQT.h
gradientWidgetQT.h
ShapePopulationGradientWidgetQT.h
Expand Down Expand Up @@ -90,6 +93,8 @@ if(ShapePopulationViewer_BUILD_SLICER_EXTENSION)

# Current_{source,binary} and Slicer_{Libs,Base} already included
set(MODULE_INCLUDE_DIRECTORIES
${vtkSlicerSRepModuleMRML_INCLUDE_DIRS}
${vtkSlicerSRepModuleLogic_INCLUDE_DIRS}
)
set(MODULE_SRCS
qSlicer${MODULE_NAME}LayoutViewFactory.cxx
Expand All @@ -109,6 +114,8 @@ if(ShapePopulationViewer_BUILD_SLICER_EXTENSION)
)
set(MODULE_TARGET_LIBRARIES
${LOCAL_PROJECT_NAME}Widget
vtkSlicerSRepModuleMRML
vtkSlicerSRepModuleLogic
)
set(MODULE_RESOURCES
)
Expand Down
4 changes: 2 additions & 2 deletions src/CSVloaderQT.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ void CSVloaderQT::on_buttonBox_accepted()
for (int i = 0; i < fileList.size(); i++)
{
QString QFilePath = fileList[i].absoluteFilePath();
if (!QFilePath.endsWith(".vtk") && !QFilePath.endsWith(".vtp"))
if (!QFilePath.endsWith(".vtk") && !QFilePath.endsWith(".vtp") && !QFilePath.endsWith(".xml") && !QFilePath.endsWith(".srep.json"))
{
fileList.removeAt(i);
i--;
std::ostringstream strs;
strs << QFilePath.toStdString() << std::endl
<< "This is not a vtk/vtp file."<< std::endl;
<< "This is not a vtk/vtp/xml/srep.json file."<< std::endl;
QMessageBox::critical(this,"Wrong file format",QString(strs.str().c_str()), QMessageBox::Ok);
}
else if(!fileList[i].exists())
Expand Down
89 changes: 89 additions & 0 deletions src/ShapePopulationBase.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,95 @@ vtkRenderWindow* ShapePopulationBase::CreateNewWindow(ShapePopulationData* a_mes
return renderWindow;
}

void ShapePopulationBase::UpdateWindows()
{
unsigned int i;
for (i = 0; i < m_meshList.size(); i++)
{
//MAPPER
vtkNew<vtkPolyDataMapper> mapper;
mapper->SetInputData(m_meshList[i]->GetPolyData());

//ACTOR
vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper);

/* VECTORS */
//Arrow
vtkNew<vtkArrowSource> arrow;
m_glyphList[i]->SetSourceConnection(arrow->GetOutputPort());
m_glyphList[i]->SetInputData(m_meshList[i]->GetPolyData());
m_glyphList[i]->ScalingOn();
m_glyphList[i]->OrientOn();
m_glyphList[i]->ClampingOff();
m_glyphList[i]->SetColorModeToColorByVector();
m_glyphList[i]->SetScaleModeToScaleByVector();
m_glyphList[i]->SetVectorModeToUseVector();
m_glyphList[i]->Update();

//Mapper & Actor
vtkNew<vtkPolyDataMapper> glyphMapper;
glyphMapper->SetInputData(m_glyphList[i]->GetOutput());
vtkNew<vtkActor> glyphActor;
glyphActor->SetMapper(glyphMapper);

/* END VECTORS */

//RENDERER
auto renderer = m_windowsList[i]->GetRenderers()->GetFirstRenderer();
renderer->RemoveAllViewProps();

renderer->AddActor(actor);
renderer->AddActor(glyphActor);
renderer->SetActiveCamera(m_headcam); //set the active camera for this renderer to main camera
renderer->ResetCamera();
//renderer->SetUseDepthPeeling(true);/*test opacity*/

// //INTERACTOR
// vtkSmartPointer<vtkRenderWindowInteractor> interactor = vtkSmartPointer<vtkRenderWindowInteractor>::New();
// renderWindow->SetInteractor(interactor);

//ANNOTATIONS (file name)
vtkSmartPointer<vtkCornerAnnotation> fileName = vtkSmartPointer<vtkCornerAnnotation>::New();
fileName->SetLinearFontScaleFactor( 2 );
fileName->SetNonlinearFontScaleFactor( 1 );
fileName->SetMaximumFontSize( 15 );
fileName->SetText(2,m_meshList[i]->GetFileName().c_str());
fileName->GetTextProperty()->SetColor(m_labelColor);
renderer->AddViewProp(fileName);

//ANNOTATIONS (attribute name)
vtkNew<vtkCornerAnnotation> attributeName;
attributeName->SetLinearFontScaleFactor(2);
attributeName->SetNonlinearFontScaleFactor(1);
attributeName->SetMaximumFontSize(15);
attributeName->SetText(0," ");
attributeName->GetTextProperty()->SetColor(m_labelColor);
renderer->AddViewProp(attributeName);

// SCALAR BAR
vtkNew<vtkScalarBarActor> scalarBar;
scalarBar->SetLookupTable(mapper->GetLookupTable());
// scalarBar->SetTitle("Title");
scalarBar->SetNumberOfLabels(5);
scalarBar->SetMaximumWidthInPixels(60);

vtkNew<vtkTextProperty> LabelProperty;
LabelProperty->SetFontSize(12);
LabelProperty->SetColor(m_labelColor);

scalarBar->SetLabelTextProperty(LabelProperty);
scalarBar->SetTitleTextProperty(LabelProperty);
renderer->AddActor2D(scalarBar);

//DISPLAY
if (m_displayMeshName == false) fileName->SetVisibility(0);
if (m_displayAttribute == false) attributeName->SetVisibility(0);
if (m_displayColorbar == false) scalarBar->SetVisibility(0);
}
RenderAll();
}

// * ///////////////////////////////////////////////////////////////////////////////////////////// * //
// * SELECTION * //
// * ///////////////////////////////////////////////////////////////////////////////////////////// * //
Expand Down
1 change: 1 addition & 0 deletions src/ShapePopulationBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class ShapePopulationBase
vtkRenderWindow* CreateNewWindow(std::string a_filePath, bool testing = false);
vtkRenderWindow* CreateNewWindow(vtkPolyData* a_popyData, std::string a_filePath, bool testing = false);
vtkRenderWindow* CreateNewWindow(ShapePopulationData* a_mesh, bool testing = false);
void UpdateWindows();

//SELECTION
unsigned int getSelectedIndex(vtkSmartPointer<vtkRenderWindow> a_selectedWindow);
Expand Down
Loading