OsiriX Documentation
repository·develop·Indexed 19 days ago
https://github.com/pixmeo/osirixOpen-source medical imaging software viewer. Documentation includes guides for building and running the odt2pdf tool using LibreOffice, OpenOffice.org, or NeoOffice; instructions for creating custom DICOM importers by implementing the GetMetadataForFile function within a CFPlug-in architecture; and details on the NSFont_OpenGL extension for creating OpenGL display lists for fonts.
What's inside OsiriX
- For more information regarding OsiriX and its open-source version, visit the official website at https://www.osirix-viewer.com.
Configure odt2pdf for OpenOffice and NeoOffice
developIf you are using distributions other than LibreOffice, you must adjust the
DYLD_LIBRARY_PATH, the path to thesofficebinary, and theURE_MORE_TYPESpath accordingly.OpenOffice.org
export DYLD_LIBRARY_PATH=/Applications/OpenOffice.org.app/Contents/basis-link/ure-link/lib /Applications/OpenOffice.org.app/Contents/MacOS/soffice "-accept=socket,host=localhost,port=2083;urp;StarOffice.ServiceManager" & ./odt2pdf -env:URE_MORE_TYPES=file:///Applications/OpenOffice.org.app/Contents/basis-link/program/offapi.rdb test.odt test.pdfNeoOffice
export DYLD_LIBRARY_PATH=/Applications/NeoOffice.app/Contents/basis-link/ure-link/lib /Applications/NeoOffice.app/Contents/MacOS/soffice "-accept=socket,host=localhost,port=2083;urp;StarOffice.ServiceManager" & ./odt2pdf -env:URE_MORE_TYPES=file:///Applications/NeoOffice.app/Contents/basis-link/program/offapi.rdb test.odt test.pdfRun odt2pdf with LibreOffice
developThe
odt2pdfbinary requires a running instance of LibreOffice configured to accept socket connections via the UNO (Universal Network Objects) interface.1. Start LibreOffice in listener mode
You must launch LibreOffice with the
--acceptflag to allow the tool to communicate with it. Note that different versions of LibreOffice may require different hyphenation for the flag (--acceptvs-accept).For LibreOffice 3.4.3+:
/Applications/LibreOffice.app/Contents/MacOS/soffice "--accept=socket,host=localhost,port=2083;urp;StarOffice.ServiceManager" &2. Execute the conversion
Set the
DYLD_LIBRARY_PATHto point to the LibreOffice URE library and run the binary with the-env:URE_MORE_TYPESflag pointing to theoffapi.rdbfile.export DYLD_LIBRARY_PATH=/Applications/LibreOffice.app/Contents/basis-link/ure-link/lib ./odt2pdf -env:URE_MORE_TYPES=file:///Applications/LibreOffice.app/Contents/basis-link/program/offapi.rdb input.odt output.pdf3. Cleanup
To stop the background LibreOffice process:
killall LibreOfficeexport DYLD_LIBRARY_PATH=/Applications/LibreOffice.app/Contents/basis-link/ure-link/lib /Applications/LibreOffice.app/Contents/MacOS/soffice "--accept=socket,host=localhost,port=2083;urp;StarOffice.ServiceManager" & ./odt2pdf -env:URE_MORE_TYPES=file:///Applications/LibreOffice.app/Contents/basis-link/program/offapi.rdb test.odt test.pdfBuild the odt2pdf tool
developTo build
odt2pdf, you must have the LibreOffice SDK (version 3.4.3 was used in this guide) installed.- Download and move the LibreOffice SDK directory to a permanent location.
- Enter the SDK directory and initialize the environment using the
setsdkenv_unixscript. - Navigate to the
odt2pdfsource directory. - Run
maketo compile the tool.
Upon successful completion, the binary will be located at
path/to/odt2pdf/build/odt2pdf.cd /path/to/LibreOffice3.4_SDK sh setsdkenv_unix cd path/to/odt2pdf makeHow the Metadata Importer plugin architecture works
developThe DICOM importer is implemented as a CFPlug-in using a COM-like architecture. The system interacts with the plugin through a factory pattern and reference counting.
Core Components:
- Factory Function (
MetadataImporterPluginFactory): The entry point used by the system to instantiate the plugin. It checks if the requestedtypeIDmatcheskMDImporterTypeIDbefore returning a new instance. - Plugin Instance (
MetadataImporterPluginType): A structure that holds theconduitInterface(the function table), thefactoryID, and arefCountfor memory management. - Interface Table (
MDImporterInterfaceStruct): A table of function pointers that defines the plugin's capabilities. The standard table includes:QueryInterface: To allow the system to request specific interfaces (likekMDImporterInterfaceIDorIUnknownUUID).AddRef/Release: For manual reference counting.GetMetadataForFile: The user-implemented metadata extraction logic.
Lifecycle:
- The system calls the factory to get an instance.
- The instance is managed via
AddRefandReleasecalls. - When the
refCountreaches zero,DeallocMetadataImporterPluginTypeis called to free the memory and unregister the factory.
- Factory Function (
Configure NSFont OpenGL error logging
developBy default, errors encountered during OpenGL display list creation are logged using
NSLog(). You can disable this class-wide logging using thesetOpenGLLogging:method onNSFont.// Disable logging for all NSFont OpenGL operations [NSFont setOpenGLLogging:NO];Create OpenGL display lists for NSFont
developThe
NSFont_OpenGLextension adds a category toNSFontthat enables the creation of OpenGL display lists for bitmaps based on a specific font. This is useful for rendering font characters directly via OpenGL.To create display lists for a range of characters, use the
makeGLDisplayListFirst:count:base:method on anNSFontinstance. You must provide a base value obtained from a call toglGenLists().// Assuming myFont is an NSFont instance // and displayListBase is the value returned from glGenLists() BOOL success = [myFont makeGLDisplayListFirst:' ' count:95 base:displayListBase]; // Returns TRUE if successful, FALSE otherwise.Reference: MetadataImporterPluginType structure
developThe
MetadataImporterPluginTypestructure defines the internal layout of a plugin instance used by the importer component.typedef struct __MetadataImporterPluginType { MDImporterInterfaceStruct *conduitInterface; CFUUIDRef factoryID; UInt32 refCount; } MetadataImporterPluginType;Implement the GetMetadataForFile function to create a DICOM importer
developTo create a custom DICOM importer for OsiriX, you must implement the
GetMetadataForFilefunction in a separate file (typicallyGetMetadataForFile.c). This function is the core logic of the importer, called by the system to extract metadata from a file.Function Signature:
Boolean GetMetadataForFile(void *thisInterface, CFMutableDictionaryRef attributes, CFStringRef contentTypeUTI, CFStringRef pathToFile);Parameters:
thisInterface: A pointer to the interface being used.attributes: ACFMutableDictionaryRefwhere you should populate the extracted metadata keys and values.contentTypeUTI: ACFStringRefrepresenting the Uniform Type Identifier of the file.pathToFile: ACFStringRefcontaining the file system path to the file being imported.
Boolean GetMetadataForFile(void *thisInterface, CFMutableDictionaryRef attributes, CFStringRef contentTypeUTI, CFStringRef pathToFile);