00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef DIOVPLN_H
00031 #define DIOVPLN_H
00032
00033 #include "dcmtk/config/osconfig.h"
00034 #include "dcmtk/ofstd/ofstring.h"
00035 #include "dcmtk/ofstd/ofcast.h"
00036
00037 #include "dcmtk/dcmimgle/diutils.h"
00038
00039 #define INCLUDE_CSTDDEF
00040 #include "dcmtk/ofstd/ofstdinc.h"
00041
00042
00043
00044
00045
00046
00047 class DcmOverlayData;
00048 class DcmLongString;
00049
00050 class DiDocument;
00051
00052
00053
00054
00055
00056
00059 class DiOverlayPlane
00060 {
00061
00062 public:
00063
00072 DiOverlayPlane(const DiDocument *docu,
00073 const unsigned int group,
00074 Uint16 alloc,
00075 const Uint16 stored,
00076 const Uint16 high);
00077
00090 DiOverlayPlane(const unsigned int group,
00091 const Sint16 left_pos,
00092 const Sint16 top_pos,
00093 const Uint16 columns,
00094 const Uint16 rows,
00095 const DcmOverlayData &data,
00096 const DcmLongString &label,
00097 const DcmLongString &description,
00098 const EM_Overlay mode);
00099
00111 DiOverlayPlane(DiOverlayPlane *plane,
00112 const unsigned int bit,
00113 Uint16 *data,
00114 Uint16 *temp,
00115 const Uint16 width,
00116 const Uint16 height,
00117 const Uint16 columns,
00118 const Uint16 rows);
00119
00122 ~DiOverlayPlane();
00123
00130 inline Sint16 getLeft(const Sint32 left_pos = 0) const
00131 {
00132 return OFstatic_cast(Sint16, OFstatic_cast(Sint32, Left) - left_pos);
00133 }
00134
00141 inline Sint16 getTop(const Sint32 top_pos = 0) const
00142 {
00143 return OFstatic_cast(Sint16, OFstatic_cast(Sint32, Top) - top_pos);
00144 }
00145
00150 inline Uint16 getWidth() const
00151 {
00152 return Width;
00153 }
00154
00159 inline Uint16 getHeight() const
00160 {
00161 return Height;
00162 }
00163
00170 inline Uint16 getRight(const Sint32 left_pos = 0) const
00171 {
00172 return (OFstatic_cast(Sint32, Left) + OFstatic_cast(Sint32, Width) - left_pos > 0) ?
00173 OFstatic_cast(Uint16, OFstatic_cast(Sint32, Left) + OFstatic_cast(Sint32, Width) - left_pos) : 0;
00174 }
00175
00182 inline Uint16 getBottom(const Sint32 top_pos = 0) const
00183 {
00184 return (OFstatic_cast(Sint32, Top) + OFstatic_cast(Sint32, Height) - top_pos > 0) ?
00185 OFstatic_cast(Uint16, OFstatic_cast(Sint32, Top) + OFstatic_cast(Sint32, Height) - top_pos) : 0;
00186 }
00187
00192 inline int isValid() const
00193 {
00194 return Valid;
00195 }
00196
00201 inline int isVisible() const
00202 {
00203 return Visible;
00204 }
00205
00208 inline void show()
00209 {
00210 Visible = 1;
00211 }
00212
00215 inline void hide()
00216 {
00217 Visible = 0;
00218 }
00219
00225 void place(const signed int left_pos,
00226 const signed int top_pos);
00227
00233 void setScaling(const double xfactor,
00234 const double yfactor);
00235
00243 void setFlipping(const int horz,
00244 const int vert,
00245 const signed long columns,
00246 const signed long rows);
00247
00256 void setRotation(const int degree,
00257 const signed long left_pos,
00258 const signed long top_pos,
00259 const Uint16 columns,
00260 const Uint16 rows);
00261
00268 void show(const double fore,
00269 const double thresh,
00270 const EM_Overlay mode);
00271
00279 int show(const Uint16 pvalue);
00280
00285 inline unsigned long getNumberOfFrames() const
00286 {
00287 return NumberOfFrames;
00288 }
00289
00294 inline double getForeground() const
00295 {
00296 return Foreground;
00297 }
00298
00303 inline double getThreshold() const
00304 {
00305 return Threshold;
00306 }
00307
00313 inline Uint16 getPValue() const
00314 {
00315 return PValue;
00316 }
00317
00322 inline EM_Overlay getMode() const
00323 {
00324 return Mode;
00325 }
00326
00331 inline int isEmbedded() const
00332 {
00333 return EmbeddedData;
00334 }
00335
00340 const char *getLabel() const
00341 {
00342 return (Label.empty()) ? OFstatic_cast(const char *, NULL) : Label.c_str();
00343 }
00344
00349 const char *getDescription() const
00350 {
00351 return (Description.empty()) ? OFstatic_cast(const char *, NULL) : Description.c_str();
00352 }
00353
00358 Uint16 getGroupNumber() const
00359 {
00360 return GroupNumber;
00361 }
00362
00378 void *getData(const unsigned long frame,
00379 const Uint16 xmin,
00380 const Uint16 ymin,
00381 const Uint16 xmax,
00382 const Uint16 ymax,
00383 const int bits,
00384 const Uint16 fore,
00385 const Uint16 back);
00386
00399 unsigned long create6xxx3000Data(Uint8 *&buffer,
00400 unsigned int &width,
00401 unsigned int &height,
00402 unsigned long &frames);
00403
00410 inline int reset(const unsigned long frame);
00411
00416 inline int getNextBit();
00417
00423 inline void setStart(const Uint16 x,
00424 const Uint16 y);
00425
00426
00427 protected:
00428
00430 Uint32 NumberOfFrames;
00432 Uint16 ImageFrameOrigin;
00433
00435 Sint16 Top;
00437 Sint16 Left;
00439 Uint16 Height;
00441 Uint16 Width;
00443 Uint16 Rows;
00445 Uint16 Columns;
00447 Uint16 BitsAllocated;
00449 Uint16 BitPosition;
00450
00452 double Foreground;
00454 double Threshold;
00456 Uint16 PValue;
00457
00459 EM_Overlay Mode;
00461 EM_Overlay DefaultMode;
00462
00464 OFString Label;
00466 OFString Description;
00467
00469 Uint16 GroupNumber;
00470
00472 int Valid;
00474 int Visible;
00475
00476
00477 private:
00478
00480 unsigned long BitPos;
00482 unsigned long StartBitPos;
00483
00485 unsigned int StartLeft;
00487 unsigned int StartTop;
00488
00490 int EmbeddedData;
00491
00493 const Uint16 *Ptr;
00495 const Uint16 *StartPtr;
00497 const Uint16 *Data;
00498
00499
00500
00501 DiOverlayPlane(const DiOverlayPlane &);
00502 DiOverlayPlane &operator=(const DiOverlayPlane &);
00503 };
00504
00505
00506
00507
00508
00509 inline int DiOverlayPlane::reset(const unsigned long frame)
00510 {
00511 int result = 0;
00512 if (Valid && (Data != NULL) && (frame >= ImageFrameOrigin) && (frame < ImageFrameOrigin + NumberOfFrames))
00513 {
00514 const unsigned long bits = (OFstatic_cast(unsigned long, StartLeft) + OFstatic_cast(unsigned long, StartTop) *
00515 OFstatic_cast(unsigned long, Columns) + frame * OFstatic_cast(unsigned long, Rows) *
00516 OFstatic_cast(unsigned long, Columns)) * OFstatic_cast(unsigned long, BitsAllocated);
00517 StartBitPos = BitPos = OFstatic_cast(unsigned long, BitPosition) + bits;
00518
00519 if (BitsAllocated == 16)
00520 StartPtr = Ptr = Data + (bits >> 4);
00521 else
00522 StartPtr = Data;
00523 result = (getRight() > 0) && (getBottom() > 0);
00524 }
00525 return result;
00526 }
00527
00528
00529 inline int DiOverlayPlane::getNextBit()
00530 {
00531 int result;
00532 if (BitsAllocated == 16)
00533 result = OFstatic_cast(int, *(Ptr++) & (1 << BitPosition));
00534 else
00535 {
00536 Ptr = StartPtr + (BitPos >> 4);
00537 result = OFstatic_cast(int, *Ptr & (1 << (BitPos & 0xf)));
00538 BitPos += BitsAllocated;
00539 }
00540 return result;
00541 }
00542
00543
00544 inline void DiOverlayPlane::setStart(const Uint16 x,
00545 const Uint16 y)
00546 {
00547 if (BitsAllocated == 16)
00548 Ptr = StartPtr + OFstatic_cast(unsigned long, y - Top) * OFstatic_cast(unsigned long, Columns) +
00549 OFstatic_cast(unsigned long, x - Left);
00550 else
00551 BitPos = StartBitPos + (OFstatic_cast(unsigned long, y - Top) * OFstatic_cast(unsigned long, Columns) +
00552 OFstatic_cast(unsigned long, x - Left)) * OFstatic_cast(unsigned long, BitsAllocated);
00553 }
00554
00555
00556 #endif
00557
00558
00559
00560
00561
00562
00563
00564
00565
00566
00567
00568
00569
00570
00571
00572
00573
00574
00575
00576
00577
00578
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588
00589
00590
00591
00592
00593
00594
00595
00596
00597
00598
00599
00600
00601
00602
00603
00604
00605
00606
00607
00608
00609
00610
00611
00612
00613
00614
00615
00616
00617
00618
00619
00620
00621
00622
00623
00624
00625
00626
00627
00628
00629
00630
00631
00632
00633
00634
00635
00636
00637
00638
00639
00640
00641
00642
00643
00644
00645
00646
00647
00648
00649
00650
00651
00652
00653
00654
00655
00656
00657
00658
00659
00660
00661
00662
00663
00664
00665
00666
00667
00668
00669
00670
00671
00672
00673
00674
00675
00676
00677
00678
00679
00680
00681
00682
00683
00684
00685
00686
00687