/** * Get an editable Dicom KeyObject Selection suitable to handle current Dicom Image. A valid object should either * reference the studyInstanceUID of the current Dicom Image or simply be empty ... */ public static KOSpecialElement findValidKOSelection(final ViewCanvas<DicomImageElement> view2d) { MediaSeries<DicomImageElement> dicomSeries = view2d.getSeries(); DicomImageElement currentImage = view2d.getImage(); if (currentImage != null && dicomSeries != null) { String currentStudyInstanceUID = TagD.getTagValue(currentImage, Tag.StudyInstanceUID, String.class); Collection<KOSpecialElement> koElementsWithReferencedSeriesInstanceUID = DicomModel.getKoSpecialElements(dicomSeries); if (koElementsWithReferencedSeriesInstanceUID != null) { for (KOSpecialElement koElement : koElementsWithReferencedSeriesInstanceUID) { if (koElement.getMediaReader().isEditableDicom()) { if (koElement.containsStudyInstanceUIDReference(currentStudyInstanceUID)) { return koElement; } } } for (KOSpecialElement koElement : koElementsWithReferencedSeriesInstanceUID) { if (koElement.getMediaReader().isEditableDicom()) { if (koElement.isEmpty()) { return koElement; } } } } } return null; }
private boolean setKeyObjectReference(boolean selectedState, Reference ref) { if (selectedState) { return addKeyObject(ref); } else { return removeKeyObject(ref); } }
/** * * @param seriesUID * @param specialElements * @return the KOSpecialElement collection for the given parameters, if the referenced seriesUID is null all the * KOSpecialElement from specialElements collection are returned. In any case all the KOSpecialElement that * are writable will be added to the returned collection whatever is the seriesUID. These KO are part of the * new created ones by users of the application */ public static final Collection<KOSpecialElement> getKoSpecialElements( Collection<DicomSpecialElement> specialElements, String seriesUID) { if (specialElements == null) { return Collections.emptySet(); } SortedSet<KOSpecialElement> koElementSet = null; for (DicomSpecialElement element : specialElements) { if (element instanceof KOSpecialElement) { KOSpecialElement koElement = (KOSpecialElement) element; Set<String> referencedSeriesInstanceUIDSet = koElement.getReferencedSeriesInstanceUIDSet(); if (seriesUID == null || referencedSeriesInstanceUIDSet.contains(seriesUID) || koElement.getMediaReader().isEditableDicom()) { if (koElementSet == null) { koElementSet = new TreeSet<>(ORDER_BY_DATE); } koElementSet.add(koElement); } } } return koElementSet == null ? Collections.emptySet() : koElementSet; }
public static Collection<KOSpecialElement> getEditableKoSpecialElements(MediaSeriesGroup group) { List<KOSpecialElement> list = getSpecialElements(group, KOSpecialElement.class); if (list != null && !list.isEmpty()) { for (int i = list.size() - 1; i >= 0; i--) { KOSpecialElement koElement = list.get(i); if (!koElement.getMediaReader().isEditableDicom()) { list.remove(i); } } return list; } return Collections.emptyList(); }
public boolean setKeyObjectReference(boolean selectedState, DicomImageElement dicomImage) { return setKeyObjectReference(selectedState, new Reference(dicomImage)); }
public void openrelatedSeries(KOSpecialElement koSpecialElement, MediaSeriesGroup patient) { if (koSpecialElement != null && patient != null) { SeriesViewerFactory plugin = UIManager.getViewerFactory(DicomMediaIO.SERIES_MIMETYPE); if (plugin != null && !(plugin instanceof MimeSystemAppFactory)) { Set<String> koSet = koSpecialElement.getReferencedSeriesInstanceUIDSet(); List<MediaSeries<MediaElement>> seriesList = new ArrayList<>(); for (MediaSeriesGroup st : this.getChildren(patient)) { for (MediaSeriesGroup s : this.getChildren(st)) { if (koSet.contains(TagD.getTagValue(s, Tag.SeriesInstanceUID))) { seriesList.add((MediaSeries<MediaElement>) s); } } } if (!seriesList.isEmpty()) { String uid = UUID.randomUUID().toString(); Map<String, Object> props = Collections.synchronizedMap(new HashMap<String, Object>()); props.put(ViewerPluginBuilder.CMP_ENTRY_BUILD_NEW_VIEWER, false); props.put(ViewerPluginBuilder.BEST_DEF_LAYOUT, false); props.put(ViewerPluginBuilder.ICON, new ImageIcon(getClass().getResource("/icon/16x16/key-images.png"))); //$NON-NLS-1$ props.put(ViewerPluginBuilder.UID, uid); ViewerPluginBuilder builder = new ViewerPluginBuilder(plugin, seriesList, this, props); ViewerPluginBuilder.openSequenceInPlugin(builder); this.firePropertyChange( new ObservableEvent(ObservableEvent.BasicAction.SELECT, uid, null, koSpecialElement)); } } } }
ref.getReferencedSOPInstanceUID(), ref.getReferencedSOPClassUID(), ref.getReferencedFrameNumber()); keyReferences.addKeyObject(koRef); SeriesViewerFactory plugin = UIManager.getViewerFactory(DicomMediaIO.SERIES_MIMETYPE); if (plugin != null && !(plugin instanceof MimeSystemAppFactory)) {
Filter<DicomImageElement> sopInstanceUIDFilter = null; if (koFilter && selectedKO.containsSeriesInstanceUIDReference(seriesInstanceUID)) { sopInstanceUIDFilter = selectedKO.getSOPInstanceUIDFilter();
@Override public DicomSpecialElement buildDicomSpecialElement(DicomMediaIO mediaIO) { if (RejectedKOSpecialElement.isRejectionKOS(mediaIO)) { return new RejectedKOSpecialElement(mediaIO); } return new KOSpecialElement(mediaIO); } });
if (selectedKO instanceof KOSpecialElement) { KOSpecialElement koElement = (KOSpecialElement) selectedKO; if (koElement.containsSopInstanceUIDReference(seriesInstanceUID, sopInstanceUID, frame)) { newSelectionState = eState.SELECTED; if (koElement.containsSopInstanceUIDReference(seriesInstanceUID, sopInstanceUID, frame)) { newSelectionState = eState.EXIST; break;
String seriesInstanceUID = TagD.getTagValue(dicomSeries, Tag.SeriesInstanceUID, String.class); if (!updatedKOSelection.containsSeriesInstanceUIDReference(seriesInstanceUID)) { continue;
public static KOSpecialElement loadDicomKeyObject(MediaSeries<DicomImageElement> dicomSeries, Attributes newDicomKO) { DicomModel dicomModel = (DicomModel) dicomSeries.getTagValue(TagW.ExplorerModel); new LoadDicomObjects(dicomModel, newDicomKO).addSelectionAndnotify(); // must be executed in the EDT for (KOSpecialElement koElement : DicomModel.getKoSpecialElements(dicomSeries)) { if (koElement.getMediaReader().getDicomObject().equals(newDicomKO)) { return koElement; } } return null; }
public boolean setKeyObjectReference(boolean selectedState, MediaSeries<DicomImageElement> series) { boolean hasDataModelChanged = false; for (DicomImageElement dicomImage : series.getSortedMedias(null)) { hasDataModelChanged |= setKeyObjectReference(selectedState, new Reference(dicomImage)); } return hasDataModelChanged; }
if (currentSelectedKO.getMediaReader().isEditableDicom()) { if (currentSelectedKO.isEmpty() || currentSelectedKO.containsStudyInstanceUIDReference(studyInstanceUID)) {
private KOSpecialElement buildKO(DicomModel model, DicomSeries s) { DicomSpecialElement dcmElement = DicomModel.getFirstSpecialElement(series, DicomSpecialElement.class); if (dcmElement != null) { DicomImageElement dcm = s.getMedia(MediaSeries.MEDIA_POSITION.FIRST, null, null); if (dcm != null && dcm.getMediaReader() instanceof DcmMediaReader) { Attributes dicomSourceAttribute = ((DcmMediaReader) dcm.getMediaReader()).getDicomObject(); Attributes attributes = DicomMediaUtils.createDicomKeyObject(dicomSourceAttribute, dcmElement.getShortLabel(), null); new LoadDicomObjects(model, attributes).addSelectionAndnotify(); // must be executed in the EDT for (KOSpecialElement koElement : DicomModel.getKoSpecialElements(s)) { if (koElement.getMediaReader().getDicomObject().equals(attributes)) { return koElement; } } } } return null; }
public void toggleKeyObjectReference(DicomImageElement dicomImage) { Reference ref = new Reference(dicomImage); // Get the SOPInstanceReferenceMap for this seriesUID Map<String, SOPInstanceReferenceAndMAC> sopInstanceReferenceBySOPInstanceUID = sopInstanceReferenceMapBySeriesUID.get(ref.getSeriesInstanceUID()); boolean isSelected = sopInstanceReferenceBySOPInstanceUID != null && sopInstanceReferenceBySOPInstanceUID.containsKey(ref.getSopInstanceUID()); setKeyObjectReference(!isSelected, ref); }
public static boolean setKeyObjectReferenceAllSeries(boolean selectedState, final ViewCanvas<DicomImageElement> view2d) { KOSpecialElement validKOSelection = getValidKOSelection(view2d); if (validKOSelection == null) { return false; // canceled } KOSpecialElement currentSelectedKO = KOManager.getCurrentKOSelection(view2d); if (validKOSelection != currentSelectedKO) { ActionState koSelection = view2d.getEventManager().getAction(ActionW.KO_SELECTION); if (koSelection instanceof ComboItemListener) { ((ComboItemListener) koSelection).setSelectedItem(validKOSelection); } } boolean hasKeyObjectReferenceChanged = false; if (validKOSelection == currentSelectedKO || currentSelectedKO == null) { // KO Toogle State is changed only if KO Selection remains the same, // or if there was no previous KO Selection hasKeyObjectReferenceChanged = validKOSelection.setKeyObjectReference(selectedState, view2d.getSeries()); if (hasKeyObjectReferenceChanged) { DicomModel dicomModel = (DicomModel) view2d.getSeries().getTagValue(TagW.ExplorerModel); // Fire an event since any view in any View2dContainer may have its KO selected state changed if (dicomModel != null) { dicomModel.firePropertyChange(new ObservableEvent(ObservableEvent.BasicAction.UPDATE, view2d, null, new SeriesEvent(SeriesEvent.Action.UPDATE, validKOSelection, "updateAll"))); //$NON-NLS-1$ } } } return hasKeyObjectReferenceChanged; }
hasKeyObjectReferenceChanged = validKOSelection.setKeyObjectReference(selectedState, currentImage);