Beispiel #1
0
 /// <summary>
 /// Initializes new Basic Image Box
 /// </summary>
 /// <param name="filmBox">Basic Film Box</param>
 /// <param name="sopClass">SOP Class UID</param>
 /// <param name="sopInstance">SOP Instance UID</param>
 public DcmImageBox(DcmFilmBox filmBox, DicomUID sopClass, DicomUID sopInstance)
 {
     _filmBox     = filmBox;
     _sopClass    = sopClass;
     _sopInstance = sopInstance;
     _dataset     = new DcmDataset(DicomTransferSyntax.ImplicitVRLittleEndian);
 }
Beispiel #2
0
 /// <summary>
 /// Initializes new Basic Image Box
 /// </summary>
 /// <param name="filmBox">Basic Film Box</param>
 /// <param name="sopClass">SOP Class UID</param>
 /// <param name="sopInstance">SOP Instance UID</param>
 /// <param name="dataset">Dataset</param>
 public DcmImageBox(DcmFilmBox filmBox, DicomUID sopClass, DicomUID sopInstance, DcmDataset dataset)
 {
     _filmBox     = filmBox;
     _sopClass    = sopClass;
     _sopInstance = sopInstance;
     _dataset     = dataset;
 }
Beispiel #3
0
        public DcmFilmBox Clone()
        {
            DcmFilmBox box = new DcmFilmBox(_session, SOPInstanceUID, Dataset.Clone());

            foreach (DcmImageBox imageBox in BasicImageBoxes)
            {
                box.BasicImageBoxes.Add(imageBox.Clone());
            }
            return(box);
        }
Beispiel #4
0
        public DcmFilmBox CreateFilmBox(DicomUID sopInstance, DcmDataset dataset)
        {
            DicomUID uid = sopInstance;

            if (uid == null || uid.UID == String.Empty)
            {
                uid = DicomUID.Generate(SOPInstanceUID, _boxes.Count + 1);
            }
            DcmFilmBox box = new DcmFilmBox(this, uid, dataset);

            _boxes.Add(box);
            return(box);
        }
Beispiel #5
0
        protected override void OnReceiveNCreateRequest(byte presentationID, ushort messageID,
                                                        DicomUID affectedClass, DicomUID affectedInstance, DcmDataset dataset)
        {
            DicomUID sopClass = Associate.GetAbstractSyntax(presentationID);

            if (affectedClass == DicomUID.BasicFilmSessionSOPClass)
            {
                if (_session != null)
                {
                    Log.Error("{0} -> Attempted to create second Basic Film Session on association", LogID);
                    SendAbort(DcmAbortSource.ServiceProvider, DcmAbortReason.NotSpecified);
                    return;
                }

                _session = new DcmFilmSession(sopClass, affectedInstance, dataset);

                SendNCreateResponse(presentationID, messageID, affectedClass, _session.SOPInstanceUID, null, DcmStatus.Success);
                return;
            }

            if (affectedClass == DicomUID.BasicFilmBoxSOPClass)
            {
                if (_session == null)
                {
                    Log.Error("{0} -> A Basic Film Session does not exist for this association", LogID);
                    SendAbort(DcmAbortSource.ServiceProvider, DcmAbortReason.NotSpecified);
                    return;
                }

                DcmFilmBox box = _session.CreateFilmBox(affectedInstance, dataset);
                if (!box.Initialize())
                {
                    SendAbort(DcmAbortSource.ServiceProvider, DcmAbortReason.NotSpecified);
                    return;
                }

                SendNCreateResponse(presentationID, messageID, affectedClass, box.SOPInstanceUID, dataset, DcmStatus.Success);
                return;
            }

            SendAbort(DcmAbortSource.ServiceProvider, DcmAbortReason.NotSpecified);
        }
Beispiel #6
0
        private void OnPrintPage(object sender, PrintPageEventArgs e)
        {
            DcmFilmBox filmBox = _filmBoxes[_current];

            //if (filmBox.MagnificationType == "CUBIC")
            //    e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
            //else
            //    e.Graphics.InterpolationMode = InterpolationMode.HighQualityBilinear;

            e.Graphics.InterpolationMode = InterpolationMode.HighQualityBilinear;

            int dpiX = e.PageSettings.PrinterResolution.X;
            int dpiY = e.PageSettings.PrinterResolution.Y;

            Rectangle bounds = GetRealPageBounds(e, _config.PreviewOnly);

            bounds.X      += (int)e.PageSettings.HardMarginX;
            bounds.Width  -= (int)e.PageSettings.HardMarginX * 2;
            bounds.Y      += (int)e.PageSettings.HardMarginY;
            bounds.Height -= (int)e.PageSettings.HardMarginY * 2;

            //Rectangle bounds = GetRealMarginBounds(e, _config.PreviewOnly);

            string format = filmBox.ImageDisplayFormat;

            if (String.IsNullOrEmpty(format))
            {
                return;
            }

            string[] parts = format.Split('\\');

            if (parts[0] == "STANDARD" && parts.Length == 2)
            {
                parts = parts[1].Split(',');
                if (parts.Length == 2)
                {
                    try {
                        int rows = int.Parse(parts[0]);
                        int cols = int.Parse(parts[1]);

                        int rowSize = bounds.Height / rows;
                        int colSize = bounds.Width / cols;

                        int imageBox = 0;

                        for (int r = 0; r < rows; r++)
                        {
                            for (int c = 0; c < cols; c++)
                            {
                                Point position = new Point();
                                position.Y = bounds.Top + (r * rowSize);
                                position.X = bounds.Left + (c * colSize);

                                if (imageBox < filmBox.BasicImageBoxes.Count)
                                {
                                    DrawImageBox(filmBox.BasicImageBoxes[imageBox], e.Graphics, position, colSize, rowSize, dpiX, dpiY);
                                }

                                imageBox++;
                            }
                        }
                    }
                    catch (Exception ex) {
#if DEBUG
                        Dicom.Debug.Log.Error("DICOM Print Error: " + ex.ToString());
#else
                        Dicom.Debug.Log.Error("DICOM Print Error: " + ex.Message);
#endif
                    }
                }
            }

            if (parts[0] == "ROW" && parts.Length == 2)
            {
                try {
                    parts = parts[1].Split(',');

                    int rows    = parts.Length;
                    int rowSize = bounds.Height / rows;

                    int imageBox = 0;

                    for (int r = 0; r < rows; r++)
                    {
                        int cols    = int.Parse(parts[r]);
                        int colSize = bounds.Width / cols;

                        for (int c = 0; c < cols; c++)
                        {
                            Point position = new Point();
                            position.Y = bounds.Top + (r * rowSize);
                            position.X = bounds.Left + (c * colSize);

                            if (imageBox < filmBox.BasicImageBoxes.Count)
                            {
                                DrawImageBox(filmBox.BasicImageBoxes[imageBox], e.Graphics, position, colSize, rowSize, dpiX, dpiY);
                            }

                            imageBox++;
                        }
                    }
                } catch (Exception ex) {
#if DEBUG
                    Dicom.Debug.Log.Error("DICOM Print Error: " + ex.ToString());
#else
                    Dicom.Debug.Log.Error("DICOM Print Error: " + ex.Message);
#endif
                }
            }

            if (parts[0] == "COL" && parts.Length == 2)
            {
                try {
                    parts = parts[1].Split(',');

                    int cols    = parts.Length;
                    int colSize = bounds.Width / cols;

                    int imageBox = 0;

                    for (int c = 0; c < cols; c++)
                    {
                        int rows    = int.Parse(parts[c]);
                        int rowSize = bounds.Height / rows;

                        for (int r = 0; r < rows; r++)
                        {
                            Point position = new Point();
                            position.Y = bounds.Top + (r * rowSize);
                            position.X = bounds.Left + (c * colSize);

                            if (imageBox < filmBox.BasicImageBoxes.Count)
                            {
                                DrawImageBox(filmBox.BasicImageBoxes[imageBox], e.Graphics, position, colSize, rowSize, dpiX, dpiY);
                            }

                            imageBox++;
                        }
                    }
                } catch (Exception ex) {
#if DEBUG
                    Dicom.Debug.Log.Error("DICOM Print Error: " + ex.ToString());
#else
                    Dicom.Debug.Log.Error("DICOM Print Error: " + ex.Message);
#endif
                }
            }

            _current++;
            e.HasMorePages = _current < _filmBoxes.Count;
            if (!e.HasMorePages)
            {
                _current = 0;
            }
        }
Beispiel #7
0
        private void OnQueryPageSettings(object sender, QueryPageSettingsEventArgs e)
        {
            DcmFilmBox filmBox = _filmBoxes[_current];

            e.PageSettings.Landscape = (filmBox.FilmOrientation == "LANDSCAPE");
        }
Beispiel #8
0
 public void AddFilmBox(DcmFilmBox box)
 {
     _filmBoxes.Add(box);
 }
Beispiel #9
0
        protected override void OnReceiveNActionRequest(byte presentationID, ushort messageID,
                                                        DicomUID requestedClass, DicomUID requestedInstance, ushort actionTypeID, DcmDataset dataset)
        {
            if (_session == null)
            {
                Log.Error("{0} -> A Basic Film Session does not exist for this association", LogID);
                SendAbort(DcmAbortSource.ServiceProvider, DcmAbortReason.NotSpecified);
                return;
            }

            DcmPrintDocument document = new DcmPrintDocument(_config, _session.Clone());

            if (requestedClass == DicomUID.BasicFilmSessionSOPClass && actionTypeID == 0x0001)
            {
                foreach (DcmFilmBox box in _session.BasicFilmBoxes)
                {
                    document.AddFilmBox(box.Clone());
                }
            }

            else if (requestedClass == DicomUID.BasicFilmBoxSOPClass && actionTypeID == 0x0001)
            {
                DcmFilmBox box = _session.FindFilmBox(requestedInstance);
                if (box == null)
                {
                    Log.Error("{0} -> Received N-ACTION request for invalid film box", LogID);
                    SendAbort(DcmAbortSource.ServiceProvider, DcmAbortReason.NotSpecified);
                    return;
                }

                document.AddFilmBox(box.Clone());
            }

            else
            {
                SendAbort(DcmAbortSource.ServiceProvider, DcmAbortReason.NotSpecified);
            }

            DcmDataset result = null;

            NPrintState state = new NPrintState();

            state.PresentationID = presentationID;
            state.Document       = document;

            //DicomUID jobUid = DicomUID.Generate(_session.SOPInstanceUID, 9999);
            //jobUid = DicomUID.Generate(jobUid, _jobs.Count + 1);

            //DcmPrintJob job = new DcmPrintJob(jobUid);
            //job.ExecutionStatus = "PENDING";
            //job.ExecutionStatusInfo = "QUEUED";
            //job.CreationDateTime = DateTime.Now;
            //job.PrintPriority = _session.PrintPriority;
            //job.PrinterName = Config.Instance.PrinterSettings.PrinterName;
            //job.Originator = Associate.CallingAE;

            //result = new DcmDataset(DicomTransferSyntax.ImplicitVRLittleEndian);
            //result.AddReferenceSequenceItem(DicomTags.ReferencedPrintJobSequenceRETIRED, DicomUID.PrintJob, job.SOPInstanceUID);

            //state.Job = job;
            //_jobs.Add(job);

            new Thread(PrintJobProc).Start(state);

            SendNActionResponse(presentationID, messageID, requestedClass, requestedInstance, actionTypeID, result, DcmStatus.Success);

            if (state.Job != null)
            {
                SendNEventReportRequest(presentationID, NextMessageID(), DicomUID.PrintJobSOPClass, state.Job.SOPInstanceUID, 1, state.Job.Dataset);
            }
        }
Beispiel #10
0
        protected override void OnReceiveNSetRequest(byte presentationID, ushort messageID,
                                                     DicomUID requestedClass, DicomUID requestedInstance, DcmDataset dataset)
        {
            if (requestedClass == DicomUID.BasicFilmSessionSOPClass)
            {
                if (_session == null)
                {
                    Log.Error("{0} -> A Basic Film Session does not exist for this association", LogID);
                    SendAbort(DcmAbortSource.ServiceProvider, DcmAbortReason.NotSpecified);
                    return;
                }

                _session.Dataset.Merge(dataset);

                SendNSetResponse(presentationID, messageID, requestedClass, requestedInstance, null, DcmStatus.Success);
                return;
            }

            if (requestedClass == DicomUID.BasicFilmBoxSOPClass)
            {
                if (_session == null)
                {
                    Log.Error("{0} -> A Basic Film Session does not exist for this association", LogID);
                    SendAbort(DcmAbortSource.ServiceProvider, DcmAbortReason.NotSpecified);
                    return;
                }

                DcmFilmBox box = _session.FindFilmBox(requestedInstance);
                if (box == null)
                {
                    Log.Error("{0} -> Received N-SET request for invalid film box", LogID);
                    SendAbort(DcmAbortSource.ServiceProvider, DcmAbortReason.NotSpecified);
                    return;
                }

                box.Dataset.Merge(dataset);

                SendNSetResponse(presentationID, messageID, requestedClass, requestedInstance, null, DcmStatus.Success);
                return;
            }

            if (requestedClass == DicomUID.BasicColorImageBoxSOPClass ||
                requestedClass == DicomUID.BasicGrayscaleImageBoxSOPClass)
            {
                if (_session == null)
                {
                    Log.Error("{0} -> A Basic Film Session does not exist for this association", LogID);
                    SendAbort(DcmAbortSource.ServiceProvider, DcmAbortReason.NotSpecified);
                    return;
                }

                DcmImageBox box = _session.FindImageBox(requestedInstance);
                if (box == null)
                {
                    Log.Error("{0} -> Received N-SET request for invalid image box", LogID);
                    SendAbort(DcmAbortSource.ServiceProvider, DcmAbortReason.NotSpecified);
                    return;
                }

                box.Dataset.Merge(dataset);

                SendNSetResponse(presentationID, messageID, requestedClass, requestedInstance, null, DcmStatus.Success);
                return;
            }

            SendAbort(DcmAbortSource.ServiceProvider, DcmAbortReason.NotSpecified);
        }
Beispiel #11
0
		public void AddFilmBox(DcmFilmBox box) {
			_filmBoxes.Add(box);
		}
Beispiel #12
0
		/// <summary>
		/// Initializes new Basic Image Box
		/// </summary>
		/// <param name="filmBox">Basic Film Box</param>
		/// <param name="sopClass">SOP Class UID</param>
		/// <param name="sopInstance">SOP Instance UID</param>
		/// <param name="dataset">Dataset</param>
		public DcmImageBox(DcmFilmBox filmBox, DicomUID sopClass, DicomUID sopInstance, DcmDataset dataset) {
			_filmBox = filmBox;
			_sopClass = sopClass;
			_sopInstance = sopInstance;
			_dataset = dataset;
		}
Beispiel #13
0
		/// <summary>
		/// Initializes new Basic Image Box
		/// </summary>
		/// <param name="filmBox">Basic Film Box</param>
		/// <param name="sopClass">SOP Class UID</param>
		/// <param name="sopInstance">SOP Instance UID</param>
		public DcmImageBox(DcmFilmBox filmBox, DicomUID sopClass, DicomUID sopInstance) {
			_filmBox = filmBox;
			_sopClass = sopClass;
			_sopInstance = sopInstance;
			_dataset = new DcmDataset(DicomTransferSyntax.ImplicitVRLittleEndian);
		}
Beispiel #14
0
		public DcmFilmBox Clone() {
			DcmFilmBox box = new DcmFilmBox(_session, SOPInstanceUID, Dataset.Clone());
			foreach (DcmImageBox imageBox in BasicImageBoxes) {
				box.BasicImageBoxes.Add(imageBox.Clone());
			}
			return box;
		}
Beispiel #15
0
		public DcmFilmBox CreateFilmBox(DicomUID sopInstance, DcmDataset dataset) {
			DicomUID uid = sopInstance;
			if (uid == null || uid.UID == String.Empty)
				uid = DicomUID.Generate(SOPInstanceUID, _boxes.Count + 1);
			DcmFilmBox box = new DcmFilmBox(this, uid, dataset);
			_boxes.Add(box);
			return box;
		}