Skip to content

Commit

Permalink
BUG: Mark translatable strings in Markups module
Browse files Browse the repository at this point in the history
  • Loading branch information
mhdiop committed Apr 30, 2024
1 parent 5e831bc commit 774acf1
Show file tree
Hide file tree
Showing 23 changed files with 134 additions and 90 deletions.
7 changes: 7 additions & 0 deletions Modules/Loadable/Markups/MRML/vtkMRMLMarkupsAngleNode.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
==============================================================================*/

// MRML includes
#include "vtkMRMLI18N.h"
#include "vtkMRMLMarkupsDisplayNode.h"
#include "vtkMRMLMarkupsAngleNode.h"
#include "vtkMRMLMeasurementAngle.h"
Expand All @@ -41,6 +42,12 @@ vtkMRMLMarkupsAngleNode::vtkMRMLMarkupsAngleNode()
this->MaximumNumberOfControlPoints = 3;
this->RequiredNumberOfControlPoints = 3;

// Set markup type GUI display name
this->TypeDisplayName = vtkMRMLTr("vtkMRMLMarkupsAngleNode", "Angle");

// Set markup short name
this->DefaultNodeNamePrefix = vtkMRMLTr("vtkMRMLMarkupsAngleNode", "A");

// Setup measurements calculated for this markup type
vtkNew<vtkMRMLMeasurementAngle> angleMeasurement;
angleMeasurement->SetName("angle");
Expand Down
6 changes: 0 additions & 6 deletions Modules/Loadable/Markups/MRML/vtkMRMLMarkupsAngleNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,6 @@ class VTK_SLICER_MARKUPS_MODULE_MRML_EXPORT vtkMRMLMarkupsAngleNode : public vt
/// Get markup type internal name
const char* GetMarkupType() override {return "Angle";};

// Get markup type GUI display name
const char* GetTypeDisplayName() override {return "Angle";};

/// Get markup short name
const char* GetDefaultNodeNamePrefix() override {return "A";};

/// Read node attributes from XML file
void ReadXMLAttributes( const char** atts) override;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
// MRML includes
#include "vtkCurveGenerator.h"
#include "vtkCurveMeasurementsCalculator.h"
#include "vtkMRMLI18N.h"
#include "vtkMRMLMeasurementArea.h"
#include "vtkMRMLMessageCollection.h"

Expand Down Expand Up @@ -52,6 +53,12 @@ vtkMRMLMarkupsClosedCurveNode::vtkMRMLMarkupsClosedCurveNode()
this->CurveGenerator->SetCurveIsClosed(true);
this->CurveMeasurementsCalculator->SetCurveIsClosed(true);

// Set markup type GUI display name
this->TypeDisplayName = vtkMRMLTr("vtkMRMLMarkupsClosedCurveNode", "Closed Curve");

// Set markup short name
this->DefaultNodeNamePrefix = vtkMRMLTr("vtkMRMLMarkupsClosedCurveNode", "CC");

// Setup measurements calculated for this markup type
vtkNew<vtkMRMLMeasurementArea> areaMeasurement;
areaMeasurement->SetEnabled(false);
Expand Down
6 changes: 0 additions & 6 deletions Modules/Loadable/Markups/MRML/vtkMRMLMarkupsClosedCurveNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,6 @@ class VTK_SLICER_MARKUPS_MODULE_MRML_EXPORT vtkMRMLMarkupsClosedCurveNode : pub
/// Get markup type internal name
const char* GetMarkupType() override {return "ClosedCurve";};

// Get markup type GUI display name
const char* GetTypeDisplayName() override {return "Closed Curve";};

/// Get markup short name
const char* GetDefaultNodeNamePrefix() override {return "CC";};

/// Copy node content (excludes basic data, such as name and node references).
/// \sa vtkMRMLNode::CopyContent
vtkMRMLCopyContentDefaultMacro(vtkMRMLMarkupsClosedCurveNode);
Expand Down
7 changes: 7 additions & 0 deletions Modules/Loadable/Markups/MRML/vtkMRMLMarkupsCurveNode.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "vtkMRMLMarkupsCurveNode.h"

// MRML includes
#include "vtkMRMLI18N.h"
#include "vtkCurveGenerator.h"
#include "vtkCurveMeasurementsCalculator.h"
#include "vtkEventBroker.h"
Expand Down Expand Up @@ -73,6 +74,12 @@ vtkMRMLMarkupsCurveNode::vtkMRMLMarkupsCurveNode()
// in place mode after placing a curve point.
this->RequiredNumberOfControlPoints = 1e6;

// Set markup type GUI display name
this->TypeDisplayName = vtkMRMLTr("vtkMRMLMarkupsCurveNode", "Curve");

// Set markup short name
this->DefaultNodeNamePrefix = vtkMRMLTr("vtkMRMLMarkupsCurveNode", "OC");

this->CleanFilter = vtkSmartPointer<vtkCleanPolyData>::New();

this->TriangleFilter = vtkSmartPointer<vtkTriangleFilter>::New();
Expand Down
6 changes: 0 additions & 6 deletions Modules/Loadable/Markups/MRML/vtkMRMLMarkupsCurveNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,6 @@ class VTK_SLICER_MARKUPS_MODULE_MRML_EXPORT vtkMRMLMarkupsCurveNode : public vt
/// Get markup type internal name
const char* GetMarkupType() override {return "Curve";};

// Get markup type GUI display name
const char* GetTypeDisplayName() override {return "Curve";};

/// Get markup short name
const char* GetDefaultNodeNamePrefix() override {return "OC";};

/// Read node attributes from XML file
void ReadXMLAttributes( const char** atts) override;

Expand Down
10 changes: 9 additions & 1 deletion Modules/Loadable/Markups/MRML/vtkMRMLMarkupsFiducialNode.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
==============================================================================*/

// MRML includes
#include "vtkMRMLI18N.h"
#include "vtkMRMLMarkupsFiducialDisplayNode.h"
#include "vtkMRMLMarkupsFiducialNode.h"
#include "vtkMRMLMarkupsFiducialStorageNode.h"
Expand All @@ -34,7 +35,14 @@ vtkMRMLNodeNewMacro(vtkMRMLMarkupsFiducialNode);


//----------------------------------------------------------------------------
vtkMRMLMarkupsFiducialNode::vtkMRMLMarkupsFiducialNode() = default;
vtkMRMLMarkupsFiducialNode::vtkMRMLMarkupsFiducialNode()
{
// Set markup type GUI display name
this->TypeDisplayName = vtkMRMLTr("vtkMRMLMarkupsFiducialNode", "Point List");

// Set markup short name
this->DefaultNodeNamePrefix = vtkMRMLTr("vtkMRMLMarkupsFiducialNode", "F");
}

//----------------------------------------------------------------------------
vtkMRMLMarkupsFiducialNode::~vtkMRMLMarkupsFiducialNode() = default;
Expand Down
6 changes: 0 additions & 6 deletions Modules/Loadable/Markups/MRML/vtkMRMLMarkupsFiducialNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,6 @@ class VTK_SLICER_MARKUPS_MODULE_MRML_EXPORT vtkMRMLMarkupsFiducialNode : public
/// Get markup type internal name
const char* GetMarkupType() override {return "Fiducial";};

// Get markup type GUI display name
const char* GetTypeDisplayName() override {return "Point List";};

/// Get markup short name
const char* GetDefaultNodeNamePrefix() override {return "F";};

/// Read node attributes from XML file
void ReadXMLAttributes( const char** atts) override;

Expand Down
7 changes: 7 additions & 0 deletions Modules/Loadable/Markups/MRML/vtkMRMLMarkupsLineNode.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
==============================================================================*/

// MRML includes
#include "vtkMRMLI18N.h"
#include "vtkMRMLMarkupsDisplayNode.h"
#include "vtkMRMLMarkupsLineNode.h"
#include "vtkMRMLMeasurementLength.h"
Expand All @@ -42,6 +43,12 @@ vtkMRMLMarkupsLineNode::vtkMRMLMarkupsLineNode()
this->MaximumNumberOfControlPoints = 2;
this->RequiredNumberOfControlPoints = 2;

// Set markup type GUI display name
this->TypeDisplayName = vtkMRMLTr("vtkMRMLMarkupsLineNode", "Line");

// Set markup short name
this->DefaultNodeNamePrefix = vtkMRMLTr("vtkMRMLMarkupsLineNode", "L");

// Setup measurements calculated for this markup type
vtkNew<vtkMRMLMeasurementLength> lengthMeasurement;
lengthMeasurement->SetName("length");
Expand Down
6 changes: 0 additions & 6 deletions Modules/Loadable/Markups/MRML/vtkMRMLMarkupsLineNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,6 @@ class VTK_SLICER_MARKUPS_MODULE_MRML_EXPORT vtkMRMLMarkupsLineNode : public vtk
/// Get markup type internal name
const char* GetMarkupType() override {return "Line";};

// Get markup type GUI display name
const char* GetTypeDisplayName() override {return "Line";};

/// Get markup short name
const char* GetDefaultNodeNamePrefix() override {return "L";};

/// Read node attributes from XML file
void ReadXMLAttributes( const char** atts) override;

Expand Down
21 changes: 21 additions & 0 deletions Modules/Loadable/Markups/MRML/vtkMRMLMarkupsNode.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "vtkMRMLMarkupsNode.h"

// MRML includes
#include "vtkMRMLI18N.h"
#include "vtkCurveGenerator.h"
#include <vtkEventBroker.h>
#include "vtkMRMLMarkupsDisplayNode.h"
Expand Down Expand Up @@ -532,6 +533,26 @@ void vtkMRMLMarkupsNode::SetLocked(int locked)
this->InvokeCustomModifiedEvent(vtkMRMLMarkupsNode::LockModifiedEvent);
}

//----------------------------------------------------------------------------
const char* vtkMRMLMarkupsNode::GetDefaultNodeNamePrefix()
{
if(this->DefaultNodeNamePrefix.empty())
{
this->DefaultNodeNamePrefix = vtkMRMLTr("vtkMRMLMarkupsNode", "M");
}
return this->DefaultNodeNamePrefix.c_str();
}

//----------------------------------------------------------------------------
const char* vtkMRMLMarkupsNode::GetTypeDisplayName()
{
if(this->TypeDisplayName.empty())
{
this->TypeDisplayName = vtkMRMLTr("vtkMRMLMarkupsNode", "Markup");
}
return this->TypeDisplayName.c_str();
}

//---------------------------------------------------------------------------
vtkMRMLMarkupsDisplayNode *vtkMRMLMarkupsNode::GetMarkupsDisplayNode()
{
Expand Down
13 changes: 12 additions & 1 deletion Modules/Loadable/Markups/MRML/vtkMRMLMarkupsNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,10 @@ class VTK_SLICER_MARKUPS_MODULE_MRML_EXPORT vtkMRMLMarkupsNode : public vtkMRML
virtual const char* GetMarkupType() {return "Markup";};

/// Get markup short name
virtual const char* GetDefaultNodeNamePrefix() {return "M";};
virtual const char* GetDefaultNodeNamePrefix();

/// Get markup type GUI display name
virtual const char* GetTypeDisplayName() override;

/// Read node attributes from XML file
void ReadXMLAttributes(const char** atts) override;
Expand Down Expand Up @@ -1029,6 +1032,14 @@ class VTK_SLICER_MARKUPS_MODULE_MRML_EXPORT vtkMRMLMarkupsNode : public vtkMRML

std::string PropertiesLabelText;

/// Store markup type GUI display name
/// \note It's displayed to the user and is therefore translated to the application language
std::string TypeDisplayName;

/// Store markup short name
/// \note It's displayed to the user and is therefore translated to the application language
std::string DefaultNodeNamePrefix;

/// Transform that moves the xyz unit vectors and origin of the interaction handles to local coordinates
vtkSmartPointer<vtkMatrix4x4> InteractionHandleToWorldMatrix;

Expand Down
7 changes: 7 additions & 0 deletions Modules/Loadable/Markups/MRML/vtkMRMLMarkupsPlaneNode.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
==============================================================================*/

// MRML includes
#include "vtkMRMLI18N.h"
#include "vtkMRMLMarkupsPlaneDisplayNode.h"
#include "vtkMRMLMarkupsPlaneNode.h"
#include "vtkMRMLMeasurementArea.h"
Expand Down Expand Up @@ -49,6 +50,12 @@ vtkMRMLMarkupsPlaneNode::vtkMRMLMarkupsPlaneNode()
this->RequiredNumberOfControlPoints = 1;
this->MaximumNumberOfControlPoints = 1;

// Set markup type GUI display name
this->TypeDisplayName = vtkMRMLTr("vtkMRMLMarkupsPlaneNode", "Plane");

// Set markup short name
this->DefaultNodeNamePrefix = vtkMRMLTr("vtkMRMLMarkupsPlaneNode", "P");

this->ObjectToBaseMatrix = vtkSmartPointer<vtkMatrix4x4>::New();
this->BaseToNodeMatrix = vtkSmartPointer<vtkMatrix4x4>::New();

Expand Down
6 changes: 0 additions & 6 deletions Modules/Loadable/Markups/MRML/vtkMRMLMarkupsPlaneNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,6 @@ class VTK_SLICER_MARKUPS_MODULE_MRML_EXPORT vtkMRMLMarkupsPlaneNode : public vt
/// Get markup type internal name
const char* GetMarkupType() override {return "Plane";};

// Get markup type GUI display name
const char* GetTypeDisplayName() override {return "Plane";};

/// Get markup short name
const char* GetDefaultNodeNamePrefix() override {return "P";};

/// Read node attributes from XML file
void ReadXMLAttributes( const char** atts) override;

Expand Down
7 changes: 7 additions & 0 deletions Modules/Loadable/Markups/MRML/vtkMRMLMarkupsROINode.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "vtkMRMLMarkupsROINode.h"

// MRML includes
#include <vtkMRMLI18N.h>
#include <vtkMRMLMarkupsROIDisplayNode.h>
#include <vtkMRMLMarkupsROIJsonStorageNode.h>
#include "vtkMRMLMeasurementVolume.h"
Expand Down Expand Up @@ -58,6 +59,12 @@ vtkMRMLMarkupsROINode::vtkMRMLMarkupsROINode()
{
this->PropertiesLabelText = "";

// Set markup type GUI display name
this->TypeDisplayName = vtkMRMLTr("vtkMRMLMarkupsROINode", "ROI");

// Set markup short name
this->DefaultNodeNamePrefix = vtkMRMLTr("vtkMRMLMarkupsROINode", "R");

this->RequiredNumberOfControlPoints = NUMBER_OF_BOX_CONTROL_POINTS;
this->MaximumNumberOfControlPoints = -1;
this->IsUpdatingControlPointsFromROI = false;
Expand Down
6 changes: 0 additions & 6 deletions Modules/Loadable/Markups/MRML/vtkMRMLMarkupsROINode.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,6 @@ class VTK_SLICER_MARKUPS_MODULE_MRML_EXPORT vtkMRMLMarkupsROINode : public vtkM
/// Get markup type internal name
const char* GetMarkupType() override {return "ROI";};

// Get markup type GUI display name
const char* GetTypeDisplayName() override {return "ROI";};

/// Get markup short name
const char* GetDefaultNodeNamePrefix() override {return "R";};

/// Copy node content (excludes basic data, such as name and node references).
/// \sa vtkMRMLNode::CopyContent
vtkMRMLCopyContentMacro(vtkMRMLMarkupsROINode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ void qSlicerSubjectHierarchyMarkupsPluginPrivate::jumpToPoint(int controlPointIn
return;
}

vtkSlicerMarkupsLogic* markupsLogic = vtkSlicerMarkupsLogic::SafeDownCast(appLogic->GetModuleLogic("Markups"));
vtkSlicerMarkupsLogic* markupsLogic = vtkSlicerMarkupsLogic::SafeDownCast(appLogic->GetModuleLogic(/*no tr*/"Markups"));
if (!markupsLogic)
{
qCritical() << Q_FUNC_INFO << ": could not get the Markups module logic.";
Expand Down Expand Up @@ -348,7 +348,7 @@ double qSlicerSubjectHierarchyMarkupsPlugin::canAddNodeToSubjectHierarchy(
return 0.0;
}

vtkSlicerMarkupsLogic* markupsLogic = vtkSlicerMarkupsLogic::SafeDownCast(appLogic->GetModuleLogic("Markups"));
vtkSlicerMarkupsLogic* markupsLogic = vtkSlicerMarkupsLogic::SafeDownCast(appLogic->GetModuleLogic(/*no tr*/"Markups"));
if (!markupsLogic)
{
qCritical() << Q_FUNC_INFO << ": could not get the Markups module logic.";
Expand Down Expand Up @@ -402,7 +402,7 @@ double qSlicerSubjectHierarchyMarkupsPlugin::canOwnSubjectHierarchyItem(vtkIdTyp
return 0.0;
}

vtkSlicerMarkupsLogic* markupsLogic = vtkSlicerMarkupsLogic::SafeDownCast(appLogic->GetModuleLogic("Markups"));
vtkSlicerMarkupsLogic* markupsLogic = vtkSlicerMarkupsLogic::SafeDownCast(appLogic->GetModuleLogic(/*no tr*/"Markups"));
if (!markupsLogic)
{
qCritical() << Q_FUNC_INFO << ": could not get the Markups module logic.";
Expand Down Expand Up @@ -800,7 +800,7 @@ void qSlicerSubjectHierarchyMarkupsPlugin::renamePoint()
QString oldName(markupsNode->GetNthControlPointLabel(componentIndex).c_str());

bool ok = false;
QString newName = QInputDialog::getText(nullptr, QString("Rename ") + oldName, "New name:", QLineEdit::Normal, oldName, &ok);
QString newName = QInputDialog::getText(nullptr, tr("Rename %1").arg(oldName), tr("New name:"), QLineEdit::Normal, oldName, &ok);
if (!ok)
{
return;
Expand Down Expand Up @@ -831,7 +831,7 @@ void qSlicerSubjectHierarchyMarkupsPlugin::refocusCamera()
// Get point index
int componentIndex = d->ViewContextMenuEventData["ComponentIndex"].toInt();

vtkSlicerMarkupsLogic* markupsLogic = vtkSlicerMarkupsLogic::SafeDownCast(appLogic->GetModuleLogic("Markups"));
vtkSlicerMarkupsLogic* markupsLogic = vtkSlicerMarkupsLogic::SafeDownCast(appLogic->GetModuleLogic(/*no tr*/"Markups"));
if (!markupsLogic)
{
qCritical() << Q_FUNC_INFO << ": could not get the Markups module logic.";
Expand Down Expand Up @@ -994,7 +994,7 @@ void qSlicerSubjectHierarchyMarkupsPlugin::editNodeTerminology()
return;
}
vtkSlicerTerminologiesModuleLogic* terminologiesLogic = vtkSlicerTerminologiesModuleLogic::SafeDownCast(
qSlicerCoreApplication::application()->moduleLogic("Terminologies"));
qSlicerCoreApplication::application()->moduleLogic(/*no tr*/"Terminologies"));
if (!terminologiesLogic)
{
qCritical() << Q_FUNC_INFO << ": Failed to get Terminologies module logic";
Expand Down
Loading

0 comments on commit 774acf1

Please sign in to comment.