Skip to content

Commit

Permalink
ENH: Only show imaging panel sliders if loaded; Start with sliders di…
Browse files Browse the repository at this point in the history
…sabled

Re #218
  • Loading branch information
cpinter committed Oct 9, 2023
1 parent 20e4db3 commit 411b5fc
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 20 deletions.
31 changes: 16 additions & 15 deletions RoomsEyeView/Logic/vtkSlicerRoomsEyeViewModuleLogic.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -452,24 +452,25 @@ void vtkSlicerRoomsEyeViewModuleLogic::BuildRoomsEyeViewTransformHierarchy()
}

//----------------------------------------------------------------------------
void vtkSlicerRoomsEyeViewModuleLogic::LoadTreatmentMachine(vtkMRMLRoomsEyeViewNode* parameterNode)
std::vector<vtkSlicerRoomsEyeViewModuleLogic::TreatmentMachinePartType>
vtkSlicerRoomsEyeViewModuleLogic::LoadTreatmentMachine(vtkMRMLRoomsEyeViewNode* parameterNode)
{
vtkMRMLScene* scene = this->GetMRMLScene();
if (!scene)
{
vtkErrorMacro("LoadTreatmentMachine: Invalid scene");
return;
return std::vector<TreatmentMachinePartType>();
}
vtkMRMLSubjectHierarchyNode* shNode = scene->GetSubjectHierarchyNode();
if (!shNode)
{
vtkErrorMacro("LoadTreatmentMachine: Failed to access subject hierarchy node");
return;
return std::vector<TreatmentMachinePartType>();
}
if (!parameterNode || !parameterNode->GetTreatmentMachineDescriptorFilePath())
{
vtkErrorMacro("LoadTreatmentMachine: Invalid parameter node");
return;
return std::vector<TreatmentMachinePartType>();
}

// Make sure the transform hierarchy is in place
Expand All @@ -484,15 +485,15 @@ void vtkSlicerRoomsEyeViewModuleLogic::LoadTreatmentMachine(vtkMRMLRoomsEyeViewN
if (!fp)
{
vtkErrorMacro("LoadTreatmentMachine: Failed to load treatment machine descriptor file '" << descriptorFilePath << "'");
return;
return std::vector<TreatmentMachinePartType>();
}
char buffer[4096];
rapidjson::FileReadStream fs(fp, buffer, sizeof(buffer));
if (this->Internal->CurrentTreatmentMachineDescription->ParseStream(fs).HasParseError())
{
vtkErrorMacro("LoadTreatmentMachine: Failed to load treatment machine descriptor file '" << descriptorFilePath << "'");
fclose(fp);
return;
return std::vector<TreatmentMachinePartType>();
}
fclose(fp);

Expand Down Expand Up @@ -521,19 +522,21 @@ void vtkSlicerRoomsEyeViewModuleLogic::LoadTreatmentMachine(vtkMRMLRoomsEyeViewN
this->Internal->EnsureTreatmentMachinePartModelNode(parameterNode, FlatPanel, true);

// Setup treatment machine model display and transforms
this->SetupTreatmentMachineModels(parameterNode);
return this->SetupTreatmentMachineModels(parameterNode);
}

//----------------------------------------------------------------------------
void vtkSlicerRoomsEyeViewModuleLogic::SetupTreatmentMachineModels(vtkMRMLRoomsEyeViewNode* parameterNode)
std::vector<vtkSlicerRoomsEyeViewModuleLogic::TreatmentMachinePartType>
vtkSlicerRoomsEyeViewModuleLogic::SetupTreatmentMachineModels(vtkMRMLRoomsEyeViewNode* parameterNode)
{
vtkMRMLScene* scene = this->GetMRMLScene();
if (!scene)
{
vtkErrorMacro("SetupTreatmentMachineModels: Invalid scene");
return;
return std::vector<TreatmentMachinePartType>();
}

std::vector<TreatmentMachinePartType> loadedParts;
for (int partIdx=0; partIdx<LastPartType; ++partIdx)
{
std::string partType = this->GetTreatmentMachinePartTypeAsString((TreatmentMachinePartType)partIdx);
Expand All @@ -548,6 +551,8 @@ void vtkSlicerRoomsEyeViewModuleLogic::SetupTreatmentMachineModels(vtkMRMLRoomsE
continue;
}

loadedParts.push_back((TreatmentMachinePartType)partIdx);

// Set color
vtkVector3d partColor(this->GetColorForPartType(partType));
partModel->CreateDefaultDisplayNodes();
Expand Down Expand Up @@ -634,17 +639,13 @@ void vtkSlicerRoomsEyeViewModuleLogic::SetupTreatmentMachineModels(vtkMRMLRoomsE
//TODO: ApplicatorHolder, ElectronApplicator?
}

//TODO: Whole patient (segmentation, CT) will need to be transformed when the table top is transformed
//vtkMRMLLinearTransformNode* patientModelTransforms = vtkMRMLLinearTransformNode::SafeDownCast(
// this->GetMRMLScene()->GetFirstNodeByName("TableTopEccentricRotationToPatientSupportTransform"));
//patientModel->SetAndObserveTransformNodeID(patientModelTransforms->GetID());
//TODO: Instead of this make the tableTop the fixed part in RAS

// Set identity transform for patient (parent transform is taken into account when getting poly data from segmentation)
vtkNew<vtkTransform> identityTransform;
identityTransform->Identity();
this->GantryPatientCollisionDetection->SetTransform(1, vtkLinearTransform::SafeDownCast(identityTransform));
this->CollimatorPatientCollisionDetection->SetTransform(1, vtkLinearTransform::SafeDownCast(identityTransform));

return loadedParts;
}

//----------------------------------------------------------------------------
Expand Down
8 changes: 5 additions & 3 deletions RoomsEyeView/Logic/vtkSlicerRoomsEyeViewModuleLogic.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,11 @@ class VTK_SLICER_ROOMSEYEVIEW_LOGIC_EXPORT vtkSlicerRoomsEyeViewModuleLogic :
public:
/// Load and setup components of the treatment machine into the scene based on its description.
/// \param parameterNode Parameter node contains the treatment machine descriptor file path.
void LoadTreatmentMachine(vtkMRMLRoomsEyeViewNode* parameterNode);
/// Set up the IEC transforms and model properties on the treatment machine models
void SetupTreatmentMachineModels(vtkMRMLRoomsEyeViewNode* parameterNode);
/// \return List of parts that were successfully set up.
std::vector<TreatmentMachinePartType> LoadTreatmentMachine(vtkMRMLRoomsEyeViewNode* parameterNode);
/// Set up the IEC transforms and model properties on the treatment machine models.
/// \return List of parts that were successfully set up.
std::vector<TreatmentMachinePartType> SetupTreatmentMachineModels(vtkMRMLRoomsEyeViewNode* parameterNode);
/// Create or get transforms taking part in the IEC logic and additional devices, and build the transform hierarchy
void BuildRoomsEyeViewTransformHierarchy();

Expand Down
2 changes: 1 addition & 1 deletion RoomsEyeView/Resources/UI/qSlicerRoomsEyeViewModule.ui
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_5">
<widget class="QLabel" name="labelImagingPanel">
<property name="text">
<string>Imaging panel:</string>
</property>
Expand Down
26 changes: 25 additions & 1 deletion RoomsEyeView/qSlicerRoomsEyeViewModuleWidget.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,15 @@ void qSlicerRoomsEyeViewModuleWidget::setup()
connect(d->SegmentSelectorWidget_PatientBody, SIGNAL(currentNodeChanged(vtkMRMLNode*)), this, SLOT(onPatientBodySegmentationNodeChanged(vtkMRMLNode*)));
connect(d->SegmentSelectorWidget_PatientBody, SIGNAL(currentSegmentChanged(QString)), this, SLOT(onPatientBodySegmentChanged(QString)));

// Disable treatment machine geometry controls until a machine is loaded
d->GantryRotationSlider->setEnabled(false);
d->CollimatorRotationSlider->setEnabled(false);
d->PatientSupportRotationSlider->setEnabled(false);
d->VerticalTableTopDisplacementSlider->setEnabled(false);
d->LongitudinalTableTopDisplacementSlider->setEnabled(false);
d->LateralTableTopDisplacementSlider->setEnabled(false);
d->ImagingPanelMovementSlider->setEnabled(false);

//TODO: Hide additional device models section until reinstated
d->AdditionalTreatmentModelsCollapsibleButton->setVisible(false);

Expand Down Expand Up @@ -577,7 +586,8 @@ void qSlicerRoomsEyeViewModuleWidget::onLoadTreatmentMachineButtonClicked()
// Load and setup models
paramNode->SetTreatmentMachineDescriptorFilePath(descriptorFilePath.toUtf8().constData());

d->logic()->LoadTreatmentMachine(paramNode);
std::vector<vtkSlicerRoomsEyeViewModuleLogic::TreatmentMachinePartType> loadedParts =
d->logic()->LoadTreatmentMachine(paramNode);

// Set treatment machine dependent properties //TODO: Use degrees of freedom from JSON
if (!treatmentMachineType.compare("VarianTrueBeamSTx"))
Expand All @@ -597,6 +607,20 @@ void qSlicerRoomsEyeViewModuleWidget::onLoadTreatmentMachineButtonClicked()
qMRMLThreeDView* threeDView = layoutManager->threeDWidget(0)->threeDView();
threeDView->resetCamera();

// Enable treatment machine geometry controls
d->GantryRotationSlider->setEnabled(true);
d->CollimatorRotationSlider->setEnabled(true);
d->PatientSupportRotationSlider->setEnabled(true);
d->VerticalTableTopDisplacementSlider->setEnabled(true);
d->LongitudinalTableTopDisplacementSlider->setEnabled(true);
d->LateralTableTopDisplacementSlider->setEnabled(true);
d->ImagingPanelMovementSlider->setEnabled(true);

// Hide controls that do not have corresponding parts loaded
bool imagingPanelsLoaded = (std::find(loadedParts.begin(), loadedParts.end(), vtkSlicerRoomsEyeViewModuleLogic::ImagingPanelLeft) != loadedParts.end() ||
std::find(loadedParts.begin(), loadedParts.end(), vtkSlicerRoomsEyeViewModuleLogic::ImagingPanelRight) != loadedParts.end());
d->labelImagingPanel->setVisible(imagingPanelsLoaded);
d->ImagingPanelMovementSlider->setVisible(imagingPanelsLoaded);

// Set orientation marker
//TODO: Add new option 'Treatment room' to orientation marker choices and merged model with actual colors (surface scalars?)
Expand Down

0 comments on commit 411b5fc

Please sign in to comment.