/* * Deletes any empty, optional modules. */ public void DeleteEmptyModulesOptional(DicomClassType nClass) { try { DicomIod IOD; int i = 0; do { IOD = DicomIodTable.Instance.FindModuleByIndex(nClass, i); if ((IOD != null) && (IOD.Usage == DicomIodUsageType.OptionalModule)) { DicomModule module = FindModule(IOD.ModuleCode); if ((module != null) && IsEmptyModule(module)) { DeleteModule(IOD.ModuleCode); } } i++; } while (IOD != null); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.ToString()); } }
/* * Returns the next empty type 1 mandatory element in the dataset */ public DicomElement GetNextEmptyElementType1(DicomElement element, DicomClassType nClass, ref string strTag, ref string strDesc) { if (element == null) { return(null); } try { DicomIod IODClass = DicomIodTable.Instance.FindClass(nClass); if (IODClass != null) { DicomIod IOD; element = GetNextElement(element, false, true); long tagValue; while (element != null) { // Get the IOD class of the element #if (LTV15_CONFIG) if (element.Tag != DemoDicomTags.Undefined) { IOD = DicomIodTable.Instance.Find(IODClass, element.Tag, DicomIodType.Element, false); tagValue = (long)element.Tag; } else { IOD = DicomIodTable.Instance.Find(IODClass, (DicomTagType)element.UserTag, DicomIodType.Element, false); tagValue = element.UserTag; } #else IOD = DicomIodTable.Instance.Find(IODClass, element.Tag, DicomIodType.Element, false); tagValue = (long)element.Tag; #endif // if the element is an empty type 1 mandatory element, update the tag string and return // the element if ((IOD != null) && (IOD.Usage == DicomIodUsageType.Type1MandatoryElement) && (element.Length == 0) && (element.Length != ELEMENT_LENGTH_MAX)) { strTag = String.Format("{0:X4}:{1:X4}", Utils.GetGroup(tagValue), Utils.GetElement(tagValue)); strDesc = IOD.Name; return(element); } element = GetNextElement(element, false, true); } } } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.ToString()); } return(element); }
bool IsSupportedIod(DicomClassType nClass) { for (int i = 0; i < m_DICOMUIDIOD.Length; i++) { if (m_DICOMUIDIOD[i].nClass == nClass) { return(true); } } return(false); }
void RemoveClasses() { DicomIod pClass = null; for (DicomClassType nClass = DicomClassType.CRImageStorage; nClass < DicomClassType.Max; nClass++) { if (!IsSupportedIod(nClass)) { pClass = DicomIodTable.Instance.FindClass(nClass); if (pClass != null) { DicomIodTable.Instance.Delete(pClass); } } } }
private void _btn_OK_Click(object sender, EventArgs e) { int nIndex; nIndex = _lstBx.SelectedIndex; if (nIndex == -1) { m_nClass = DicomClassType.Max; } else { m_nClass = dataDictionary[nIndex]; } m_nFlags = DicomDataSetInitializeFlags.ExplicitVR | DicomDataSetInitializeFlags.LittleEndian; }
/* * Parses through the data set, finds the mandatory type 1 elements, and adds them * to the ListView. */ public void Update(MyDicomDataSet ds, DicomClassType nClass) { try { if (ds == null) { return; } MyListViewItem currentItem; string strTag = ""; string strDesc = ""; DicomElement element; element = ds.GetFirstEmptyElementType1(nClass, ref strTag, ref strDesc); while (element != null) { currentItem = new MyListViewItem(); currentItem.Text = strTag; currentItem.SubItems.Add(strDesc); currentItem.SubItems.Add(""); currentItem.m_Element = element; currentItem.ImageIndex = (int)MyIconIndex.Missing; MyTreeNode treeNode = m_TreeView.FindNodeByElement(element, null, null); if (treeNode != null) { m_TreeView.FindNodeByElement(element, null, null).ImageIndex = (int)MyIconIndex.Missing; m_TreeView.FindNodeByElement(element, null, null).SelectedImageIndex = (int)MyIconIndex.Missing; Items.Add(currentItem); } element = ds.GetNextEmptyElementType1(element, nClass, ref strTag, ref strDesc); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
public MYDICOMUIDIOD(DicomClassType type, string zUID) { nClass = type; pszUID = zUID; }
public ModalityItem(string Value, string Description, DicomClassType ClassType) { m_strValue = Value; m_strDescription = Description; m_DicomClassType = ClassType; }
public ModalityItem() { m_strValue = ""; m_strDescription = ""; m_DicomClassType = (DicomClassType)0; }
/* * Traverse dataset as a list, and for each empty element do the following: * Type 3 sequence: if entire sequence empty, delete the sequence * Type 3 element: delete element */ public void DeleteEmptyElementsType3(DicomClassType nClass) { try { DicomElement PrevElement = null; DicomElement element; DicomIod IODClass = DicomIodTable.Instance.FindClass(nClass); if (IODClass != null) { DicomIod IOD; element = GetFirstElement(null, false, true); PrevElement = null; while (element != null) { // Get the IOD class of the element. #if (LTV15_CONFIG) if (element.Tag != DemoDicomTags.Undefined) { IOD = DicomIodTable.Instance.Find(IODClass, element.Tag, DicomIodType.Element, false); } else { IOD = DicomIodTable.Instance.Find(IODClass, (DicomTagType)element.UserTag, DicomIodType.Element, false); } #else IOD = DicomIodTable.Instance.Find(IODClass, element.Tag, DicomIodType.Element, false); #endif if ((IOD != null) && (IOD.Usage == DicomIodUsageType.OptionalElement)) { if (element.Length == ELEMENT_LENGTH_MAX) // Sequence { bool bEmptySequence = IsEmptySequence(element); if (bEmptySequence) { DeleteElement(element); element = PrevElement; // if deleting the first element, PrevElement is null, // therefore we must call GetFirstElement if (element == null) { element = GetFirstElement(null, false, true); } } } else if (element.Length == 0) // Empty element { DeleteElement(element); element = PrevElement; // if deleting the first element, PrevElement is null, // therefore we must call GetFirstElement if (element == null) { element = GetFirstElement(null, false, true); } } } PrevElement = element; element = GetNextElement(element, false, true); } } } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.ToString()); } }
public MyAppSettings() { querySCPServers = new MyServerList(); queryMWLServers = new MyServerList(); storeServers = new MyServerList(); clientAE = defaultClientAE; clientCertificate = string.Empty; privateKey = string.Empty; privateKeyPassword = "******"; logLowLevel = true; showHelpOnStart = true; #if LTV20_CONFIG if (Is64Bit()) { printerName = "LEADTOOLS 20 PrintToPACS 64-bit"; } else { printerName = "LEADTOOLS 20 PrintToPACS 32-bit"; } #endif string strCommonLocation = Path.GetDirectoryName(Application.ExecutablePath); strCommonLocation = Path.GetDirectoryName(strCommonLocation); strCommonLocation = Path.GetDirectoryName(strCommonLocation); strCommonLocation = Path.GetDirectoryName(strCommonLocation); strCommonLocation += "\\bin\\common\\xml"; if (File.Exists(strCommonLocation + "\\" + "SC-basic-ds.xml")) { secondaryCapturePath = strCommonLocation + "\\" + "SC-basic-ds.xml"; } else { secondaryCapturePath = ""; } secondaryCaptureCompression = DicomImageCompressionType.None; if (File.Exists(strCommonLocation + "\\" + "SC-Multi-Frame True Color Image-ds.xml")) { secondaryCaptureColorPath = strCommonLocation + "\\" + "SC-Multi-Frame True Color Image-ds.xml"; } else { secondaryCaptureColorPath = ""; } secondaryCaptureColorCompression = DicomImageCompressionType.None; if (File.Exists(strCommonLocation + "\\" + "SC-Multi-Frame Grayscale Byte-ds.xml")) { secondaryCaptureGrayPath = strCommonLocation + "\\" + "SC-Multi-Frame Grayscale Byte-ds.xml"; } else { secondaryCaptureGrayPath = ""; } secondaryCaptureGrayCompression = DicomImageCompressionType.None; if (File.Exists(strCommonLocation + "\\" + "EncapsulatedPDF-Template-ds.xml")) { PdfPath = strCommonLocation + "\\" + "EncapsulatedPDF-Template-ds.xml"; } else { PdfPath = ""; } TempDir = ""; UseResample = false; clientPort = 1000; selectedtype = DicomClassType.SCImageStorage; autodelete = false; capturetype = CaptureType.FullScreen; DefaultSCPServer = 0; DefaultMWLServer = 0; DefaultStoreServer = 0; wiaVersion = 0; if (Is64Bit()) { DataPath = MySettings.GetFolderPath() + "\\SerializedData_64.ser"; } else { DataPath = MySettings.GetFolderPath() + "\\SerializedData_32.ser"; } FirstRun = true; LastSelectedIndex = -1; }
/* * Creates a new dataset based off of the MWL dataset */ public CreateDatasetReturn CreateDataset() { CreateDatasetReturn nRet = CreateDatasetReturn.GeneralError; try { // Check for a selected node if (_globals.m_TreeResult.SelectedNode == null) { return(CreateDatasetReturn.NoItemSelected); } // Make sure that the modality is supported nRet = CreateDatasetReturn.ModalityNotFound; string strModality = Utils.GetStringValue(((MyTreeNode)_globals.m_TreeResult.SelectedNode).m_DS, DemoDicomTags.Modality, false); DicomClassType nClass = DicomClassType.SCImageStorage; // use SCImageStorage if we cannot find the modality for (int i = 0; i < _globals.m_ModalityTable.Length; i++) { if (strModality == _globals.m_ModalityTable[i].m_strValue) { // Modality was found, change return type to Success nClass = _globals.m_ModalityTable[i].m_DicomClassType; nRet = CreateDatasetReturn.Success; break; } } // Initialize dataset MyDicomDataSet ds = new MyDicomDataSet(); ds.Initialize(nClass, DicomDataSetInitializeFlags.ImplicitVR | DicomDataSetInitializeFlags.LittleEndian | DicomDataSetInitializeFlags.AddMandatoryElementsOnly | DicomDataSetInitializeFlags.AddMandatoryModulesOnly); ds.MapMWLtoDS(((MyTreeNode)_globals.m_TreeResult.SelectedNode).m_DS); ds.SetTagSpecificCharacterSet(); ds.SetTagInstanceNumber(1); // Set Pixel Data DicomElement PixelDataElement = ds.FindFirstElement(null, DemoDicomTags.PixelData, true); if (PixelDataElement != null) { ds.DeleteElement(PixelDataElement); PixelDataElement = ds.InsertElement(null, false, DemoDicomTags.PixelData, DicomVRType.OB, false, 0); } // use RGB as default Photometric Interpretation DicomImagePhotometricInterpretationType nPhotometric = DicomImagePhotometricInterpretationType.Rgb; if (rasterImageViewer.Image != null) { if (rasterImageViewer.Image.Order == Leadtools.RasterByteOrder.Gray) { nPhotometric = DicomImagePhotometricInterpretationType.Monochrome2; } else if (Convert.ToInt32(rasterImageViewer.Image.Order) <= 8) { nPhotometric = DicomImagePhotometricInterpretationType.PaletteColor; } else { nPhotometric = DicomImagePhotometricInterpretationType.Rgb; } ds.InsertImage(PixelDataElement, rasterImageViewer.Image, 0, DicomImageCompressionType.None, nPhotometric, 0, 0, DicomSetImageFlags.AutoSetVoiLut); } ds.DeleteEmptyElementsType3(nClass); ds.DeleteEmptyModulesOptional(nClass); if (nPhotometric != DicomImagePhotometricInterpretationType.PaletteColor) { if (ds.IsEmptyModule(DicomModuleType.PaletteColorLookupTable)) { ds.DeleteModule(DicomModuleType.PaletteColorLookupTable); } } // Generate new series instance UID and SOP Instance UID ds.InsertUID(DemoDicomTags.SeriesInstanceUID); ds.InsertUID(DemoDicomTags.SOPInstanceUID); // If the MWL already had a study instance UID, we use that // If not, generate a new UID ds.GenerateStudyInstanceUID(); _globals.m_nClass = nClass; _globals.m_DS = ds; } catch (Exception ex) { MessageBox.Show(ex.ToString()); } return(nRet); }