dvcache.h

来自「转化为DIB位图再显示出来的dicom文件C++代码」· C头文件 代码 · 共 972 行 · 第 1/2 页

H
972
字号
    }    /** gets number of cache entries     *     ** @return number of cache entries     */    inline Uint32 getCount() const    {        return List.size();    }    /** sets internal cursor to specified position in cache list     *     ** @param  idx  index position in cache list (starting with 0)     *     ** @return OFTrue if successful, OFFalse if 'idx' is invalid     */    inline OFBool gotoItem(Uint32 idx)    {        OFBool result = OFFalse;        Iterator = List.begin();        OFListIterator(ItemStruct *) last = List.end();        while (Iterator != last)        {            if (idx == 0)            {                result = OFTrue;                break;            }            idx--;            ++Iterator;        }        return result;    }        /** sets internal cursor to first position in cache list     *     ** @return OFTrue if successful, OFFalse if list is empty     */    inline OFBool gotoFirst()    {        OldIterator = Iterator;        Iterator = List.begin();        return (Iterator != List.end());    }        /** sets internal cursor to next position in cache list     *     ** @return OFTrue if successful, OFFalse if new position is invalid     */    inline OFBool gotoNext()    {        OFListIterator(ItemStruct *) last = List.end();        if (Iterator != last)            Iterator++;        return (Iterator != last);    }        /** sets internal cursor to last visited position in cache list     *     ** @return OFTrue if successful,     *          OFFalse if last visited position was invalid or the last one in the list     */    inline OFBool reset()    {        OFBool result = OFFalse;        OFListIterator(ItemStruct *) last = List.end();        if (OldIterator != last)        {            Iterator = OldIterator;            OldIterator = last;            result = OFTrue;        }        return result;    }        /** checks whether an item with the specified UID exists in the cache list     *     ** @param  uid  UID which should be checked     *     ** @return OFTrue if such an item exists, OFFalse otherwise     */    inline OFBool isElem(const OFString &uid)    {        OFBool result = OFFalse;        Iterator = List.begin();        OFListIterator(ItemStruct *) last = List.end();        while (Iterator != last)        {            const ItemStruct *item = (*Iterator);            if (item != NULL)            {                if (item->UID == uid)                {                    result = OFTrue;                    break;                }            }            ++Iterator;        }        return result;    }    /** gets review status of the current (selected) series     *     ** @return hierarchical status code if successful, 'isNew' otherwise     */    inline DVIFhierarchyStatus getStatus() const    {        const ItemStruct *item = getItem();        return (item != NULL) ? item->Status : DVIF_objectIsNew;    }    /** gets type of all instances in the series     *     ** @return type of all instances     */    inline DVPSInstanceType getType() const    {        const ItemStruct *item = getItem();        return (item != NULL) ? item->Type : DVPSI_image;    }    /** gets reference to current (selected) series     *     ** @return pointer to ItemStruct if successful, NULL otherwise     */    inline ItemStruct *getItem() const    {        return (Iterator != List.end()) ? (*Iterator) : (ItemStruct *)NULL;    }    /** adds a new item to the cache list.     *  sets internal cursor to new position.     *     ** @param  uid       unique identifier     *  @param  status    review status (optional)     */    inline void addItem(const OFString &uid,                        const DVIFhierarchyStatus status = DVIF_objectIsNew)    {        ItemStruct *item = new ItemStruct(uid, status);        List.push_back(item);        Iterator = --List.end();                // set to new position    }    /** updates hierarchical/review status for all list items.     *     ** @return resulting review status (summary of all items)     */    inline DVIFhierarchyStatus updateStatus()    {        OFListIterator(ItemStruct *) first = List.begin();        OFListIterator(ItemStruct *) last = List.end();        OFListIterator(ItemStruct *) iter = first;        DVIFhierarchyStatus status = DVIF_objectIsNew;        while (iter != last)        {            ItemStruct *item = (*iter);            if (item != NULL)            {                item->Status = item->List.updateStatus();                switch (item->Status)                {                    case DVIF_objectIsNew:                        if (status == DVIF_objectIsNotNew)                            status = DVIF_objectContainsNewSubobjects;                        break;                    case DVIF_objectIsNotNew:                        if (iter == first)                            status = DVIF_objectIsNotNew;                        else if (status == DVIF_objectIsNew)                            status = DVIF_objectContainsNewSubobjects;                        break;                    case DVIF_objectContainsNewSubobjects:                        status  = DVIF_objectContainsNewSubobjects;                        break;                }            }            ++iter;        }        return status;    } protected:    /// list of series    OFList<ItemStruct *> List;    /// internal cursor to current (selected) list item    OFListIterator(ItemStruct *) Iterator;    /// last visited position in item list    OFListIterator(ItemStruct *) OldIterator;};/* ------------------------------ *//** A class to handle a study cache (list of items). *  This is the highest level in the hierarchical cache structure. *  This class is used by DVInterface. The internal structure *  is a list of DVSeriesCache. */class DVStudyCache{ public:    /** Internal structure defining the list items.     */    struct ItemStruct    {        /** Constructor.         *  sets internal member variables.         *         ** @param  uid       unique identifier         *  @param  status    review status (optional)         */        ItemStruct(const OFString &uid,                   const DVIFhierarchyStatus status = DVIF_objectIsNew)          : UID(uid),            Status(status),            List()        {}            /// instance UID        OFString UID;        /// review status for the series        DVIFhierarchyStatus Status;        /// list of series within this study        DVSeriesCache List;    };    /** Constructor.     */    DVStudyCache()      : List(),        Iterator()    {        Iterator = List.end();    }    /** Destructor     */    virtual ~DVStudyCache()    {        clear();    }    /** reset all member variables to initial state     *  delete all list items.     */    inline void clear()    {        Iterator = List.begin();        OFListIterator(ItemStruct *) last = List.end();        while (Iterator != last)        {                 delete (*Iterator);            Iterator = List.erase(Iterator);        }        List.clear();        Iterator = List.end();    }    /** checks whether study cache is empty     *     ** @return OFTrue if cache is empty, OFFalse otherwise     */    inline OFBool empty() const    {        return List.empty();    }    /** gets number of cache entries     *     ** @return number of cache entries     */    inline Uint32 getCount() const    {        return List.size();    }    /** sets internal cursor to specified position in cache list     *     ** @param  idx  index position in cache list (starting with 0)     *     ** @return OFTrue if successful, OFFalse if 'idx' is invalid     */    inline OFBool gotoItem(Uint32 idx)    {        OFBool result = OFFalse;        Iterator = List.begin();        OFListIterator(ItemStruct *) last = List.end();        while (Iterator != last)        {            if (idx == 0)            {                result = OFTrue;                break;            }            idx--;            ++Iterator;        }        return result;    }        /** sets internal cursor to first position in cache list     *     ** @return OFTrue if successful, OFFalse if list is empty     */    inline OFBool gotoFirst()    {        //OldIterator = Iterator;        Iterator = List.begin();        return (Iterator != List.end());    }        /** sets internal cursor to next position in cache list     *     ** @return OFTrue if successful, OFFalse if new position is invalid     */    inline OFBool gotoNext()    {        OFListIterator(ItemStruct *) last = List.end();        if (Iterator != last)            Iterator++;        return (Iterator != last);    }        /** checks whether an item with the specified UID exists in the cache list     *     ** @param  uid  UID which should be checked     *     ** @return OFTrue if such an item exists, OFFalse otherwise     */    inline OFBool isElem(const OFString &uid)    {        OFBool result = OFFalse;        Iterator = List.begin();        OFListIterator(ItemStruct *) last = List.end();        while (Iterator != last)        {            const ItemStruct *item = (*Iterator);            if (item != NULL)            {                if (item->UID == uid)                {                    result= OFTrue;                    break;                }            }            ++Iterator;        }        return result;    }    /** gets review status of the current (selected) sstudy     *     ** @return hierarchical status code if successful, 'isNew' otherwise     */    inline DVIFhierarchyStatus getStatus() const    {        const ItemStruct *item = getItem();        return (item != NULL) ? item->Status : DVIF_objectIsNew;    }    /** gets reference to current (selected) study     *     ** @return pointer to ItemStruct if successful, NULL otherwise     */    inline ItemStruct *getItem() const    {        return (Iterator != List.end()) ? (*Iterator) : (ItemStruct *)NULL;    }    /** adds a new item to the cache list.     *  sets internal cursor to new position.     *     ** @param  uid       unique identifier     *  @param  status    review status (optional)     */    inline void addItem(const OFString &uid,                        const DVIFhierarchyStatus status = DVIF_objectIsNew)    {        ItemStruct *item = new ItemStruct(uid, status);        List.push_back(item);        Iterator = --List.end();                // set to new position    }    /** updates hierarchical/review status for all list items.     *     ** @return resulting review status (summary of all items)     */    inline void updateStatus()    {        OFListIterator(ItemStruct *) iter = List.begin();        OFListIterator(ItemStruct *) last = List.end();        while (iter != last)        {            ItemStruct *item = (*iter);            if (item != NULL)                item->Status = item->List.updateStatus();            ++iter;        }    } protected:    /// list of studies    OFList<ItemStruct *> List;    /// internal cursor to current (selected) list item    OFListIterator(ItemStruct *) Iterator;};#endif/* * * CVS/RCS Log: * $Log: dvcache.h,v $ * Revision 1.16  2005/12/08 16:03:30  meichel * Changed include path schema for all DCMTK header files * * Revision 1.15  2005/04/04 10:11:57  meichel * Module dcmpstat now uses the dcmqrdb API instead of imagectn for maintaining *   the index database * * Revision 1.14  2001/06/01 15:50:11  meichel * Updated copyright header * * Revision 1.13  2000/10/16 11:39:10  joergr * Added method allowing to select an instance by instance UID and SOP class * UID (without series and study UID). Required for composite references in * DICOM SR. * * Revision 1.12  2000/06/30 09:08:39  joergr * Fixed bug in database cache routines (re. study status). * * Revision 1.11  2000/05/30 13:37:15  joergr * Renamed GrayscaleHardcopy to HardcopyGrayscale (which is the correct term * according to the DICOM standard). * * Revision 1.10  2000/03/08 16:28:47  meichel * Updated copyright header. * * Revision 1.9  1999/09/08 17:03:00  joergr * Added support for new instance types in database (grayscale hardcopy and * stored print). * * Revision 1.8  1999/08/17 10:32:54  joergr * Added Doc++ styled comments. * Corrected wrong return type for method 'getImageSize()'. * * Revision 1.7  1999/05/03 11:01:08  joergr * Minor code purifications to keep Sun CC 2.0.1 quiet. * * Revision 1.6  1999/04/29 15:25:36  joergr * Added PresentationLabel to index file. * * Revision 1.5  1999/04/27 11:20:49  joergr * Add remaining member variables to member initialization list to avoid * compiler warnings. * * Revision 1.4  1999/02/24 20:14:39  joergr * Added support for presentation state caching (e.g. pstate description). * Removed unused methods. * * Revision 1.3  1999/02/19 18:56:08  joergr * Added new methods to interate through Caches (getFirst/getNext) - needed * for delete routines in Interface class. * * Revision 1.2  1999/02/19 09:45:19  joergr * Changed some comments, corrected typos and formatting. * * Revision 1.1  1999/02/18 18:50:18  joergr * Re-implemented methods to access index file (delete methods are still * missing). * * */

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?