Skip to content

Commit

Permalink
ENH: Terminology manual editing works from Colors module
Browse files Browse the repository at this point in the history
- Move Colors widget classes into Colors module
  - The Colors module related widget classes have been in Libs/MRML/Widgets, but that way they cannot possibly use Terminology features. They need to be moved to the Colors module to facilitate this
    - Classes in Testing and DesignerPlugins folders using the moved classes have also been moved to Colors module
  - Remove FileName member from vtkMRMLColorNode, as it was not used (moreover, there were comments explaining why it is not used)
- Move roles enum to qMRMLItemDelegate to consolidate access: Previously the qMRMLColorModel was in MRMLWidgets, but after moving it to the Colors module (so that the Color widgets have access to Terminologies widgets) the delegate did not have access to the enum. With the enum moved to the delegate now this is solved. The PointerRole was deleted from the enum because it was not used anywhere.
- Create terminology editor widgets for editing from item delegate
- Get and set model data correctly in the new item delegate
- Add functions to color node for get/set terminology as/from string (also add GetColorNameAutoGenerated)
- Make coded entries in color property struct in color node simple pointer, and delete them in destructor
- Add back PointerRole to be able to access the color node from a model item
- Allow empty terminology and anatomic region context names in terminologies logic
- Change CSV column separator to underscore
- Style fixes

Re Slicer#6975, Slicer#7593
  • Loading branch information
cpinter committed Jan 10, 2025
1 parent f33cfc4 commit 0862686
Show file tree
Hide file tree
Showing 63 changed files with 2,808 additions and 1,080 deletions.
278 changes: 229 additions & 49 deletions Libs/MRML/Core/vtkMRMLColorNode.cxx

Large diffs are not rendered by default.

43 changes: 25 additions & 18 deletions Libs/MRML/Core/vtkMRMLColorNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,20 @@ class VTK_MRML_EXPORT vtkMRMLColorNode : public vtkMRMLStorableNode
virtual int GetLastType () { return this->File; }

/// return a text string describing the color look up table type
virtual const char * GetTypeAsString();
virtual const char* GetTypeAsString();

/// TypeModifiedEvent is generated when the type of the color look up table changes
enum
{
TypeModifiedEvent = 20002
TypeModifiedEvent = 20002
};

/// Get name of a color from its index (index is 0-based)
/// \sa GetColorIndexByName()
const char *GetColorName(int ind);
const char* GetColorName(int ind);

/// Get whether color name for given index was auto-generated.
bool GetColorNameAutoGenerated(int ind);

/// Return the index associated with this color name, which can then be used
/// to get the color. Returns -1 on failure.
Expand Down Expand Up @@ -151,6 +154,17 @@ class VTK_MRML_EXPORT vtkMRMLColorNode : public vtkMRMLStorableNode
vtkCodedEntry* GetTerminologyTypeModifier(int ind);
vtkCodedEntry* GetTerminologyAnatomicRegion(int ind);
vtkCodedEntry* GetTerminologyAnatomicRegionModifier(int ind);
std::string GetTerminologyAsString(int ind);
static std::string GetTerminologyAsString(std::string terminologyContextName,
vtkCodedEntry* category, vtkCodedEntry* type, vtkCodedEntry* typeModifier,
//std::string anatomicContextName="", //TODO: Needed?
vtkCodedEntry* anatomicRegion=nullptr, vtkCodedEntry* anatomicRegionModifier=nullptr);

bool SetTerminologyFromString(int ind, std::string terminologyString);
std::string SetTerminologyFromString(int ind, std::string terminologyString,
vtkCodedEntry* category, vtkCodedEntry* type, vtkCodedEntry* typeModifier,
//std::string anatomicContextName="", //TODO: Needed?
vtkCodedEntry* anatomicRegion=nullptr, vtkCodedEntry* anatomicRegionModifier=nullptr);

///
/// Get the number of colors in the table
Expand All @@ -161,11 +175,6 @@ class VTK_MRML_EXPORT vtkMRMLColorNode : public vtkMRMLStorableNode
/// Return 1 if the color exists, 0 otherwise
virtual bool GetColor(int ind, double color[4]) = 0;

///
/// Name of the file name from which to read color information
vtkSetStringMacro(FileName);
vtkGetStringMacro(FileName);

///
/// Most color nodes will implement a look up table, so provide a top level
/// get method
Expand Down Expand Up @@ -221,14 +230,16 @@ class VTK_MRML_EXPORT vtkMRMLColorNode : public vtkMRMLStorableNode
std::string Name;
// Name is automatically generated (e.g., from color)
bool NameAutoGenerated{ true };
vtkSmartPointer<vtkCodedEntry> Category;
vtkSmartPointer<vtkCodedEntry> Type;
vtkSmartPointer<vtkCodedEntry> TypeModifier;
vtkSmartPointer<vtkCodedEntry> AnatomicRegion;
vtkSmartPointer<vtkCodedEntry> AnatomicRegionModifier;
vtkCodedEntry* Category{ nullptr };
vtkCodedEntry* Type{ nullptr };
vtkCodedEntry* TypeModifier{ nullptr };
vtkCodedEntry* AnatomicRegion{ nullptr };
vtkCodedEntry* AnatomicRegionModifier{ nullptr };
// Context name in case it originates from a terminology context
std::string ContextName;
};

bool GetProperty(int ind, PropertyType& prop);
bool GetProperty(int ind, PropertyType& prop);

///
/// Set values in the names vector from the colors in the node
Expand All @@ -248,10 +259,6 @@ class VTK_MRML_EXPORT vtkMRMLColorNode : public vtkMRMLStorableNode
/// A vector of names for the color table elements
std::vector<PropertyType> Properties;

///
/// A file name to read text attributes from
char* FileName;

///
/// the string used for an unnamed color
char* NoName;
Expand Down
Loading

0 comments on commit 0862686

Please sign in to comment.