changeset 205:234681297600

documented orthanc.LookupDictionary()
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 03 Jul 2024 12:35:13 +0200
parents 65ad095c25d8
children 4e6079e27965
files CodeAnalysis/CustomFunctions.json CodeAnalysis/GenerateOrthancSDK.py Sources/Autogenerated/orthanc.pyi Sources/Autogenerated/sdk_GlobalFunctions.impl.h Sources/Plugin.cpp
diffstat 5 files changed, 47 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/CodeAnalysis/CustomFunctions.json	Wed Jul 03 12:21:32 2024 +0200
+++ b/CodeAnalysis/CustomFunctions.json	Wed Jul 03 12:35:13 2024 +0200
@@ -87,5 +87,25 @@
       }
     ],
     "return_sdk_type" : "void"
+  },
+
+  {
+    "comment" : "New in release 3.2",
+    "short_name" : "LookupDictionary",
+    "implementation" : "LookupDictionary",
+    "documentation" : {
+      "description" : [ "Get information about the given DICOM tag." ],
+      "args" : {
+        "name" : "The name of the DICOM tag."
+      },
+      "return" : "Dictionary containing the requested information."
+    },
+    "args" : [
+      {
+        "sdk_name" : "name",
+        "sdk_type" : "const char *"
+      }
+    ],
+    "return_sdk_type" : "Dictionary"
   }
 ]
--- a/CodeAnalysis/GenerateOrthancSDK.py	Wed Jul 03 12:21:32 2024 +0200
+++ b/CodeAnalysis/GenerateOrthancSDK.py	Wed Jul 03 12:35:13 2024 +0200
@@ -180,6 +180,7 @@
         elif a['sdk_type'] in [ 'int32_t', 'uint32_t', 'uint8_t', 'uint16_t', 'uint64_t' ]:
             arg_type = 'int'
         elif a['sdk_type'] == 'Callable':
+            # This is only used to generate the documentation file "orthanc.pyi"
             arg_type = a['callable_type']
         else:
             raise Exception('Argument type not implemented: %s' % a['sdk_type'])
@@ -212,6 +213,9 @@
         documentation['return_type'] = 'str'
     elif f['return_sdk_type'] in [ 'int32_t', 'uint32_t', 'uint16_t', 'int64_t' ]:
         documentation['return_type'] = 'int'
+    elif f['return_sdk_type'] == 'Dictionary':
+        # This is only used to generate the documentation file "orthanc.pyi"
+        documentation['return_type'] = 'dict'
     else:
         raise Exception('Return type not implemented: %s' % f['return_sdk_type'])
 
--- a/Sources/Autogenerated/orthanc.pyi	Wed Jul 03 12:21:32 2024 +0200
+++ b/Sources/Autogenerated/orthanc.pyi	Wed Jul 03 12:35:13 2024 +0200
@@ -2156,6 +2156,19 @@
     """
     ...
 
+# Get information about the given DICOM tag
+def LookupDictionary(name: str) -> dict:
+    """
+    Get information about the given DICOM tag.
+
+    Args:
+      name (str): The name of the DICOM tag.
+
+    Returns:
+      dict: Dictionary containing the requested information.
+    """
+    ...
+
 class IncomingHttpRequestFilter(typing.Protocol):
     def __call__(self, uri: str, method: HttpMethod, ip: str, headers: dict, get: dict) -> bool:
         ...
--- a/Sources/Autogenerated/sdk_GlobalFunctions.impl.h	Wed Jul 03 12:21:32 2024 +0200
+++ b/Sources/Autogenerated/sdk_GlobalFunctions.impl.h	Wed Jul 03 12:35:13 2024 +0200
@@ -23,6 +23,7 @@
 
 
 // Forward declaration of the custom global functions
+extern PyObject *LookupDictionary(PyObject* module, PyObject *args);
 extern PyObject *RegisterIncomingHttpRequestFilter(PyObject* module, PyObject *args);
 extern PyObject *RegisterOnChangeCallback(PyObject* module, PyObject *args);
 extern PyObject *RegisterOnStoredInstanceCallback(PyObject* module, PyObject *args);
@@ -2020,6 +2021,8 @@
     "Generated from C function OrthancPluginUncompressImage()" },
   { "WriteFile", sdk_OrthancPluginWriteFile, METH_VARARGS,
     "Generated from C function OrthancPluginWriteFile()" },
+  { "LookupDictionary", LookupDictionary, METH_VARARGS,
+    "Implemented in C++ function LookupDictionary()" },
   { "RegisterIncomingHttpRequestFilter", RegisterIncomingHttpRequestFilter, METH_VARARGS,
     "Implemented in C++ function RegisterIncomingHttpRequestFilter()" },
   { "RegisterOnChangeCallback", RegisterOnChangeCallback, METH_VARARGS,
--- a/Sources/Plugin.cpp	Wed Jul 03 12:21:32 2024 +0200
+++ b/Sources/Plugin.cpp	Wed Jul 03 12:35:13 2024 +0200
@@ -82,34 +82,34 @@
        **/
       PythonLock lock;
       
-      PythonObject kw(lock, PyDict_New());
+      PythonObject dict(lock, PyDict_New());
 
       {
         PythonObject tmp(lock, PyLong_FromUnsignedLong(entry.group));
-        PyDict_SetItemString(kw.GetPyObject(), "Group", tmp.GetPyObject());
+        PyDict_SetItemString(dict.GetPyObject(), "Group", tmp.GetPyObject());
       }
 
       {
         PythonObject tmp(lock, PyLong_FromUnsignedLong(entry.element));
-        PyDict_SetItemString(kw.GetPyObject(), "Element", tmp.GetPyObject());
+        PyDict_SetItemString(dict.GetPyObject(), "Element", tmp.GetPyObject());
       }
 
       {
         PythonObject tmp(lock, PyLong_FromUnsignedLong(entry.vr));
-        PyDict_SetItemString(kw.GetPyObject(), "ValueRepresentation", tmp.GetPyObject());
+        PyDict_SetItemString(dict.GetPyObject(), "ValueRepresentation", tmp.GetPyObject());
       }
 
       {
         PythonObject tmp(lock, PyLong_FromUnsignedLong(entry.minMultiplicity));
-        PyDict_SetItemString(kw.GetPyObject(), "MinMultiplicity", tmp.GetPyObject());
+        PyDict_SetItemString(dict.GetPyObject(), "MinMultiplicity", tmp.GetPyObject());
       }
 
       {
         PythonObject tmp(lock, PyLong_FromUnsignedLong(entry.maxMultiplicity));
-        PyDict_SetItemString(kw.GetPyObject(), "MaxMultiplicity", tmp.GetPyObject());
+        PyDict_SetItemString(dict.GetPyObject(), "MaxMultiplicity", tmp.GetPyObject());
       }
       
-      return kw.Release();
+      return dict.Release();
     }
     else
     {
@@ -289,11 +289,6 @@
    **/
   
   {
-    PyMethodDef f = { "LookupDictionary", LookupDictionary, METH_VARARGS, "" };
-    functions.push_back(f);
-  }
-  
-  {
     PyMethodDef f = { "CreateImageFromBuffer", CreateImageFromBuffer, METH_VARARGS, "" };
     functions.push_back(f);
   }