Slicer  5.0
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
vtkSlicerTerminologiesModuleLogic.h
Go to the documentation of this file.
1 /*==============================================================================
2 
3  Program: 3D Slicer
4 
5  Copyright (c) Laboratory for Percutaneous Surgery (PerkLab)
6  Queen's University, Kingston, ON, Canada. All Rights Reserved.
7 
8  See COPYRIGHT.txt
9  or http://www.slicer.org/copyright/copyright.txt for details.
10 
11  Unless required by applicable law or agreed to in writing, software
12  distributed under the License is distributed on an "AS IS" BASIS,
13  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  See the License for the specific language governing permissions and
15  limitations under the License.
16 
17  This file was originally developed by Csaba Pinter, PerkLab, Queen's University
18  and was supported through the Applied Cancer Research Unit program of Cancer Care
19  Ontario with funds provided by the Ontario Ministry of Health and Long-Term Care
20 
21 ==============================================================================*/
22 
23 #ifndef __vtkSlicerTerminologiesModuleLogic_h
24 #define __vtkSlicerTerminologiesModuleLogic_h
25 
26 // Slicer includes
27 #include "vtkSlicerModuleLogic.h"
28 
29 #include "vtkSlicerTerminologiesModuleLogicExport.h"
30 
31 #include <vtkVector.h>
32 
33 class vtkStringArray;
37 
39 class VTK_SLICER_TERMINOLOGIES_LOGIC_EXPORT vtkSlicerTerminologiesModuleLogic :
41 {
42 public:
45  void PrintSelf(ostream& os, vtkIndent indent) override;
46 
49  {
50  public:
52  { };
53  CodeIdentifier(std::string codingSchemeDesignator, std::string codeValue, std::string codeMeaning)
54  : CodingSchemeDesignator(codingSchemeDesignator)
55  , CodeValue(codeValue)
56  , CodeMeaning(codeMeaning)
57  { };
58  std::string CodingSchemeDesignator;
59  std::string CodeValue;
60  std::string CodeMeaning; // Human readable name (not required for ID)
61  };
62 
64  static const char* GetNameAutoGeneratedAttributeName() { return "Terminologies.AutoUpdateNodeName"; };
66  static const char* GetColorAutoGeneratedAttributeName() { return "Terminologies.AutoUpdateNodeColor"; };
67 
73  bool LoadContextFromFile(std::string filePath);
77  std::string LoadTerminologyFromFile(std::string filePath);
81  std::string LoadAnatomicContextFromFile(std::string filePath);
86  bool LoadTerminologyFromSegmentDescriptorFile(std::string contextName, std::string filePath);
89  bool LoadAnatomicContextFromSegmentDescriptorFile(std::string contextName, std::string filePath);
90 
92  void GetLoadedTerminologyNames(std::vector<std::string> &terminologyNames);
94  void GetLoadedTerminologyNames(vtkStringArray* terminologyNames);
96  void GetLoadedAnatomicContextNames(std::vector<std::string> &anatomicContextNames);
98  void GetLoadedAnatomicContextNames(vtkStringArray* anatomicContextNames);
99 
104  bool GetCategoriesInTerminology(std::string terminologyName, std::vector<CodeIdentifier>& categories);
109  bool FindCategoriesInTerminology(std::string terminologyName, std::vector<CodeIdentifier>& categories, std::string search);
113  bool GetCategoryInTerminology(std::string terminologyName, CodeIdentifier categoryId, vtkSlicerTerminologyCategory* categoryObject);
115  int GetNumberOfCategoriesInTerminology(std::string terminologyName);
120  bool GetNthCategoryInTerminology(std::string terminologyName, int categoryIndex, vtkSlicerTerminologyCategory* category);
121 
126  bool GetTypesInTerminologyCategory(std::string terminologyName, CodeIdentifier categoryId, std::vector<CodeIdentifier>& types);
131  bool FindTypesInTerminologyCategory(std::string terminologyName, CodeIdentifier categoryId, std::vector<CodeIdentifier>& types, std::string search);
135  bool GetTypeInTerminologyCategory(std::string terminologyName, CodeIdentifier categoryId, CodeIdentifier typeId, vtkSlicerTerminologyType* typeObject);
137  int GetNumberOfTypesInTerminologyCategory(std::string terminologyName, vtkSlicerTerminologyCategory* category);
144  bool GetNthTypeInTerminologyCategory(std::string terminologyName, vtkSlicerTerminologyCategory* category, int typeIndex, vtkSlicerTerminologyType* type);
145 
150  bool GetTypeModifiersInTerminologyType(std::string terminologyName, CodeIdentifier categoryId, CodeIdentifier typeId, std::vector<CodeIdentifier>& typeModifiers);
154  bool GetTypeModifierInTerminologyType(std::string terminologyName,
155  CodeIdentifier categoryId, CodeIdentifier typeId, CodeIdentifier modifierId, vtkSlicerTerminologyType* typeModifier);
157  int GetNumberOfTypeModifiersInTerminologyType(std::string terminologyName, vtkSlicerTerminologyCategory* category, vtkSlicerTerminologyType* type);
165  bool GetNthTypeModifierInTerminologyType(std::string terminologyName, vtkSlicerTerminologyCategory* category, vtkSlicerTerminologyType* type, int typeModifierIndex, vtkSlicerTerminologyType* typeModifier);
166 
171  bool GetRegionsInAnatomicContext(std::string anatomicContextName, std::vector<CodeIdentifier>& regions);
174  bool FindRegionsInAnatomicContext(std::string anatomicContextName, std::vector<CodeIdentifier>& regions, std::string search);
178  bool GetRegionInAnatomicContext(std::string anatomicContextName, CodeIdentifier regionId, vtkSlicerTerminologyType* regionObject);
179 
184  bool GetRegionModifiersInAnatomicRegion(std::string anatomicContextName, CodeIdentifier regionId, std::vector<CodeIdentifier>& regionModifiers);
188  bool GetRegionModifierInAnatomicRegion(std::string anatomicContextName,
189  CodeIdentifier regionId, CodeIdentifier modifierId, vtkSlicerTerminologyType* regionModifier);
190 
196  bool FindTypeInTerminologyBy3dSlicerLabel(std::string terminologyName, std::string slicerLabel, vtkSlicerTerminologyEntry* entry);
197 
199  static CodeIdentifier CodeIdentifierFromTerminologyCategory(vtkSlicerTerminologyCategory* category);
201  static CodeIdentifier CodeIdentifierFromTerminologyType(vtkSlicerTerminologyType* type);
202 
206  static std::string SerializeTerminologyEntry(vtkSlicerTerminologyEntry* entry);
207 
211  static std::string SerializeTerminologyEntry(
212  std::string terminologyContextName,
213  std::string categoryValue, std::string categorySchemeDesignator, std::string categoryMeaning,
214  std::string typeValue, std::string typeSchemeDesignator, std::string typeMeaning,
215  std::string modifierValue, std::string modifierSchemeDesignator, std::string modifierMeaning,
216  std::string anatomicContextName,
217  std::string regionValue, std::string regionSchemeDesignator, std::string regionMeaning,
218  std::string regionModifierValue, std::string regionModifierSchemeDesignator, std::string regionModifierMeaning );
219 
224  bool DeserializeTerminologyEntry(std::string serializedEntry, vtkSlicerTerminologyEntry* entry);
225 
227  static std::string GetInfoStringFromTerminologyEntry(vtkSlicerTerminologyEntry* entry);
228 
229 public:
230  vtkGetStringMacro(UserContextsPath);
231  vtkSetStringMacro(UserContextsPath);
232 
233 protected:
236 
237  void SetMRMLSceneInternal(vtkMRMLScene* newScene) override;
238 
240  void LoadDefaultTerminologies();
242  void LoadDefaultAnatomicContexts();
244  void LoadUserContexts();
245 
246 protected:
248  char* UserContextsPath{nullptr};
249 
250 private:
252  void operator=(const vtkSlicerTerminologiesModuleLogic&) = delete;
253 
254  class vtkInternal;
255  vtkInternal* Internal;
256  friend class vtkInternal;
257 };
258 
259 #endif
void PrintSelf(ostream &os, vtkIndent indent) override
static vtkSlicerModuleLogic * New()
The Usual vtk class functions.
static const char * GetColorAutoGeneratedAttributeName()
Node attribute name for color auto generated.
Information needed to uniquely identify a terminology code.
Terminology property type object.
A set of MRML Nodes that supports serialization and undo/redo.
Definition: vtkMRMLScene.h:57
virtual void SetMRMLSceneInternal(vtkMRMLScene *newScene)
static const char * GetNameAutoGeneratedAttributeName()
Node attribute name for name auto generated.
CodeIdentifier(std::string codingSchemeDesignator, std::string codeValue, std::string codeMeaning)
Terminology property category object.