123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431 |
- /****************************************************************
- * Name: DicomQuery.hpp
- *
- ****************************************************************/
- #ifndef _INCLUDE_DICOM_QUERY_
- #define _INCLUDE_DICOM_QUERY_
- /////////////////////////////////////////////////////////////////////
- //
- class QueryTreeNode;
- class QueryTreeRoot;
- class QueryTreePatient;
- class QueryTreeStudy;
- class QueryTreeSeries;
- class QueryTreeImage;
- typedef BOOL (*QueryFindCallback) (const void * Para, UINT16 Status, const QueryTreeNode * ql);
- typedef BOOL (*QueryMoveCallback) (const void * Para, UINT16 Status, DICOMImage * DicomImage);
- typedef BOOL (*QueryMoveCallbackEx) (const void * Para, QueryTreeRoot * Root, UINT16 Status, DICOMImage * DicomImage);
- typedef BOOL (*QueryTreeDetachCallback) (const void * Para, const QueryTreeNode * ql);
- typedef BOOL (*MoveCompletedCallback) (
- const void * Para,
- QueryTreeRoot * Root,
- UINT16 Status,
- UINT16 NbOfRemaining,
- UINT16 NbOfCompleted,
- UINT16 NbOfFailed,
- UINT16 NbOfWarning);
- class QuerySCU;
- /////////////////////////////////////////////////////////////////////
- // class QueryTreeNode
- class DICOM_API QueryTreeNode
- {
- public:
- ArrayOfPtr < QueryTreeNode *> * Children;
- const DICOMDataSet *ResultDDS;
- tQueryLevel Tag;
- UINT32 lParam;
- DString SOPInstanceUID;
- protected:
- QueryTreeNode * TreeUp; // Tree level links upwards
- public:
- QueryTreeNode ()
- {
- Children = NULL;
- ResultDDS = NULL;
- Tag = tQInvalidLevel;
- lParam = 0;
- TreeUp = NULL;
- }
- virtual ~QueryTreeNode () { } ;
- virtual void Detach (void) ;
- virtual BOOL Expand (void) = 0;
- virtual BOOL Load (ArrayOfPtr < DICOMImage * > *);
- virtual BOOL Load (void);
- QueryTreeNode * GetParent (void) const { return TreeUp; }
- BOOL CheckConsistency (void) const;
- const QueryTreeRoot * UpToRoot (void) const
- {
- const QueryTreeNode * ql = this;
- while (ql -> TreeUp)
- ql = ql -> TreeUp;
- return ((QueryTreeRoot *)ql);
- }
- QueryTreeNode * FindDescendant (const char * theSOPInstanceUID)
- {
- if (SOPInstanceUID == theSOPInstanceUID)
- return this;
-
- if (Tag == tQImageLevel)
- return NULL;
-
- ArrayIterator < QueryTreeNode * > Iter (Children);
- while (Iter)
- {
- QueryTreeNode * Child = Iter ();
- if (Child->SOPInstanceUID == theSOPInstanceUID)
- return Child;
- if (Child->Tag == tQImageLevel)
- continue;
- QueryTreeNode * ql = Child->FindDescendant (theSOPInstanceUID);
- if (ql) return ql;
- }
- return NULL;
- }
- virtual void Dump (void) const;
- BOOL DoQuery (ArrayOfPtr <DICOMDataSet * > * ResultADDO);
- void OnQueryConfirm (const DICOMDataSet * DDS, UINT16 Status);
- void OnRetrieveConfirm (const DICOMDataSet * DDS, UINT16 Status);
- void OnRetrieveCompleted (UINT16 Status, UINT16 R, UINT16 C, UINT16 F, UINT16 W);
- BOOL ExpandToLeaf (void);
- protected:
- void ClearSendCallbackFlag (void);
- virtual BOOL LoadImage (ArrayOfPtr < DICOMImage * > *);
- virtual BOOL LoadImage (void);
- static BOOL DummyQueryCallback (const void * SThis, UINT16 Status, const QueryTreeNode * ql);
- static BOOL DummyRetrieveCallback (const void * SThis, UINT16 Status, DICOMImage * DicomImage);
- static BOOL DummyRetrieveCallbackEx (const void * SThis, QueryTreeRoot * Root, UINT16 Status, DICOMImage * DicomImage);
- static BOOL DummyDetachCallback (const void * SThis, const QueryTreeNode * ql);
- static BOOL DummyRetrieveCompletedCallback (const void * SThis, QueryTreeRoot * Root, UINT16 Status, UINT16 R, UINT16 C, UINT16 F, UINT16 W);
- virtual BOOL QueryCallback (UINT16 Status, QueryTreeNode * ql);
- virtual BOOL RetrieveCallback (UINT16 Status, DICOMImage * DicomImage);
- protected:
- virtual void Set (const DICOMDataSet * DDS) = 0;
- virtual void Clapse (void) { Detach () ; };
- virtual BOOL IsImageExistInLocal (void);
- void Add (QueryTreeNode * ql) { ql->TreeUp = this; Children->Add(ql); }
- BOOL UpdateQueryCriteria (tQueryLevel Level) const;
- BOOL DoRetrieve (void);
- void Disconnect (void);
- protected:
- friend class QueryTreeRoot;
- };
- /////////////////////////////////////////////////////////////////////
- // class QueryTreeRoot
- class DICOM_API QueryTreeRoot : public QueryTreeNode
- {
- public:
- bool TryLoadFromCache;
- bool DetachBeforeExpand;
- public:
- bool IsConnected (void) const
- {
- return (! m_bDisconnected);
- }
- protected:
- bool m_bDisconnected;
- private:
- mutable QueryFindCallback m_QueryCallback;
- mutable QueryMoveCallback m_RetrieveCallback;
- mutable QueryMoveCallbackEx m_RetrieveCallbackEx;
- mutable QueryTreeDetachCallback m_DetachCallback;
- mutable MoveCompletedCallback m_MoveCompletedCallback;
- mutable const void * m_pQCBPara;
- mutable const void * m_pRCBPara;
- mutable const void * m_pDCBPara;
- mutable const void * m_pCCBPara;
- QuerySCU * m_pDicomQuery;
- QueryCriteria * m_pQueryCriteria;
- const Modality * m_pAttachedModality;
- char m_MoveDestination [64]; // (0000,0600)
- tQueryRoot m_QueryRoot;
- tQueryLevel m_QueryLevel;
- DStringArray m_arSOPInstanceUIDSent;
- protected:
- bool ShouldICallback (DString SOPInstanceUID) ;
- bool ShouldICallback (const char * SOPInstanceUID) ;
- public:
- QueryTreeRoot ();
- QueryTreeRoot (const QueryTreeRoot & fromRoot);
- ~QueryTreeRoot () { Clapse (); };
- void SetQueryCallback (QueryFindCallback Callback, const void * Arg) const;
- void SetRetrieveCallback (QueryMoveCallback Callback, const void * Arg) const;
- void SetRetrieveCallbackEx (QueryMoveCallbackEx CallbackEx, const void * Arg) const;
- void SetDetachCallback (QueryTreeDetachCallback Callback, const void * Arg) const;
- void SetRetrieveCompletedCallback (MoveCompletedCallback Callback, const void * Arg) const;
- virtual void Detach (void);
- virtual BOOL Expand (void);
- virtual BOOL Load (ArrayOfPtr < DICOMImage * > *);
- virtual BOOL Load (void);
- virtual BOOL LoadDirect (tQueryLevel Level, const char * SOPInstanceUID);
- BOOL LoadDirectEx (tQueryLevel Level,
- const char * PatientID,
- const char * StudyInstanceUID,
- const char * SeriesInstanceUID,
- const char * SOPInstanceUID);
- void SetQueryLevel (tQueryLevel queryLevel) { m_QueryLevel = queryLevel; }
- tQueryLevel GetQueryLevel (void) const { return m_QueryLevel; }
- void SetQueryCriteria (class QueryCriteria *);
- QueryCriteria * GetQueryCriteria (void) const { return m_pQueryCriteria ; }
- BOOL ConnectTo (const Modality * pAttachedModality);
- const Modality * GetModality (void) const { return m_pAttachedModality; }
- BOOL Disconnect (void);
- BOOL SetMoveDestinationModality (const Modality * pMoveDestinationModality);
- protected:
- virtual void Set (const DICOMDataSet *);
- virtual void Clapse (void);
- virtual void Dump (void) const;
- friend QueryTreeNode;
- friend QueryTreePatient;
- friend QueryTreeStudy;
- friend QueryTreeSeries;
- friend QueryTreeImage;
- };
- /////////////////////////////////////////////////////////////////////
- // class QueryTreePatient
- class DICOM_API QueryTreePatient : public QueryTreeNode
- {
- public:
- QueryTreePatient ()
- {
- Tag = tQPatientLevel;
- };
- ~QueryTreePatient () { Clapse (); };
- virtual BOOL Expand (void);
- virtual void Set (const DICOMDataSet *);
- protected:
- BOOL Expand (BOOL FromParent);
- QueryTreePatient (const DICOMDataSet * DDS)
- {
- Tag = tQPatientLevel;
- Set (DDS);
- };
- friend QueryTreeRoot;
- };
- /////////////////////////////////////////////////////////////////////
- // class QueryTreeStudy
- class DICOM_API QueryTreeStudy : public QueryTreeNode
- {
- public:
- QueryTreeStudy ()
- {
- Tag = tQStudyLevel;
- }
- ~QueryTreeStudy () { Clapse (); };
- virtual BOOL Expand (void);
- virtual void Set (const DICOMDataSet *);
- protected:
- BOOL Expand (BOOL FromParent);
- QueryTreeStudy (const DICOMDataSet * DDS)
- {
- Tag = tQStudyLevel;
- Set (DDS);
- }
- friend QueryTreePatient;
- };
- /////////////////////////////////////////////////////////////////////
- // class QueryTreeStudy
- class DICOM_API QueryTreeSeries : public QueryTreeNode
- {
- public:
- QueryTreeSeries ()
- {
- Tag = tQSeriesLevel;
- }
- ~QueryTreeSeries () { Clapse (); };
- virtual BOOL Expand (void);
- virtual void Set (const DICOMDataSet *);
- protected:
- BOOL Expand (BOOL FromParent);
- QueryTreeSeries (const DICOMDataSet * DDS)
- {
- Tag = tQSeriesLevel;
- Set (DDS);
- }
- friend QueryTreeStudy;
- };
- /////////////////////////////////////////////////////////////////////
- // class QueryTreeImage
- class DICOM_API QueryTreeImage : public QueryTreeNode
- {
- public:
- QueryTreeImage ()
- {
- Tag = tQImageLevel;
- ImageIcon = NULL;
- DicomImage = NULL;
- }
- ~QueryTreeImage ()
- { Clapse (); };
- virtual BOOL Expand (void);
- virtual void Set (const DICOMDataSet *);
- virtual BOOL Load (ArrayOfPtr < DICOMImage * > *);
- virtual BOOL Load (void);
- DICOMImageIcon * GetImageIcon (void) { return ImageIcon; };
- DICOMImageIcon * SetImageIcon (DICOMImageIcon * newIcon)
- {
- DICOMImageIcon * oldIcon = ImageIcon;
- ImageIcon = newIcon;
- return oldIcon;
- }
- virtual void Detach (void)
- {
- QueryTreeNode::Detach ();
- if (ImageIcon) delete ImageIcon;
- if (DicomImage) delete DicomImage;
- ImageIcon = NULL;
- DicomImage = NULL;
- }
- protected:
- DICOMImageIcon * ImageIcon;
- DICOMImage * DicomImage;
- protected:
- QueryTreeImage (const DICOMDataSet * DDS)
- {
- Tag = tQImageLevel;
- ImageIcon = NULL;
- DicomImage = NULL;
- Set (DDS);
- }
- virtual BOOL LoadImage (ArrayOfPtr < DICOMImage * > * pImageArray) { return Load (pImageArray); }
- virtual BOOL LoadImage (void);
- BOOL LoadImageFromLocal (void);
- BOOL LoadImageFromRemote (void);
- BOOL DoLoadImageFromLocal (void);
- BOOL DoLoadImageFromRemote (void);
- virtual BOOL IsImageExistInLocal (void);
- private:
- BOOL LoadImageNoCallback (void);
- friend QueryTreeSeries;
- };
- /////////////////////////////////////////////////////////////////////
- inline BOOL QueryTreeNode::DummyQueryCallback (const void * Para, UINT16 Status, const QueryTreeNode * ql)
- {
- return false;
- }
- inline BOOL QueryTreeNode::DummyRetrieveCallback (const void * Para, UINT16 Status, DICOMImage * DicomImage)
- {
- return false;
- }
- inline BOOL QueryTreeNode::DummyRetrieveCallbackEx (const void * Para, QueryTreeRoot * Root, UINT16 Status, DICOMImage * DicomImage)
- {
- return false;
- }
- inline BOOL QueryTreeNode::DummyDetachCallback (const void * Para, const QueryTreeNode * ql)
- {
- return false;
- }
- inline BOOL QueryTreeNode::DummyRetrieveCompletedCallback (const void * SThis, QueryTreeRoot * Root, UINT16 Status, UINT16 R, UINT16 C, UINT16 F, UINT16 W)
- {
- return false;
- }
- /////////////////////////////////////////////////////////////////////
- DICOM_API inline bool operator == (const QueryTreeNode & qlA, const QueryTreeNode & qlB)
- {
- return (qlA.SOPInstanceUID == qlB.SOPInstanceUID);
- }
- DICOM_API inline bool operator != (const QueryTreeNode & qlA, const QueryTreeNode & qlB)
- {
- return (qlA.SOPInstanceUID != qlB.SOPInstanceUID);
- }
- #endif
|