CVB++ 15.0
data_matrix.hpp
1#pragma once
2
3#include "reader_2d_config_base.hpp"
4
5namespace Cvb
6{
7 CVB_BEGIN_INLINE_NS
8
9 namespace Barcode
10 {
11 using namespace Internal;
12
13
15
18 {
19public:
21
27 {
28 if(levels_ != levels)
29 SetDirty();
30 levels_ = levels;
31 }
32 DataMatrixLevels Levels() const
33 {
34 return levels_;
35 };
36
37
39
45 {
46 if(formats_ != formats)
47 SetDirty();
48 formats_ = formats;
49 }
50
52
58 {
59 return formats_;
60 };
61
63
68 void SetMinSize(int minSize)
69 {
70 if(minSize < MinSizeLimit_ ||
71 minSize > maxSize_)
72 throw std::runtime_error("MinSize out of range");
73 if(minSize_ != minSize)
74 SetDirty();
75 minSize_ = static_cast<short>(minSize);
76 }
77
79
84 int MinSize() const
85 {
86 return static_cast<int>(minSize_);
87 };
88
89
91
96 void SetMaxSize(int maxSize)
97 {
98 if(maxSize < minSize_ ||
99 maxSize > MaxSizeLimit_)
100 throw std::runtime_error("MaxSize out of range");
101 if(maxSize_ != maxSize)
102 SetDirty();
103 maxSize_ = static_cast<short>(maxSize);
104 }
105
107
112 int MaxSize() const
113 {
114 return static_cast<int>(maxSize_);
115 };
116
118
123 void SetAllowRectangular(bool rectangular)
124 {
125 SetDirty();
126 rectangular_ = rectangular;
127 }
128
130
135 bool AllowRectangular() const
136 {
137 return rectangular_;
138 };
139
143
145
150 void SetAllowDistorted(bool distorted)
151 {
152 SetDirty();
153 distorted_ = distorted;
154 }
155
157
162 bool AllowDistorted() const
163 {
164 return distorted_;
165 };
166
167
169
175 {
176 if(subType_ != subType)
177 SetDirty();
178 subType_ = subType;
179 }
180
182
188 {
189 return subType_;
190 };
191
192
194
200 {
201 if(pharmaCode2DBar1_ != pharmaCode2DBar1)
202 SetDirty();
203 pharmaCode2DBar1_ = pharmaCode2DBar1;
204 }
205
207
213 {
214 return pharmaCode2DBar1_;
215 };
216
217
219
225 {
226 if(pharmaCode2DBar2_ != pharmaCode2DBar2)
227 SetDirty();
228 pharmaCode2DBar2_ = pharmaCode2DBar2;
229 }
230
232
238 {
239 return pharmaCode2DBar2_;
240 };
241
242
244
250 {
251 if(pharmaCode2DBar3_ != pharmaCode2DBar3)
252 SetDirty();
253 pharmaCode2DBar3_ = pharmaCode2DBar3;
254 }
255
257
263 {
264 return pharmaCode2DBar3_;
265 };
266
267
269
275 {
276 if(pharmaCode2DBar4_ != pharmaCode2DBar4)
277 SetDirty();
278 pharmaCode2DBar4_ = pharmaCode2DBar4;
279 }
280
282
288 {
289 return pharmaCode2DBar4_;
290 };
291
292
294
300 {
301 if(pharmaCode2DBar5_ != pharmaCode2DBar5)
302 SetDirty();
303 pharmaCode2DBar5_ = pharmaCode2DBar5;
304 }
305
307
313 {
314 return pharmaCode2DBar5_;
315 };
316
317
319
325 {
326 if(pharmaCode2DBar6_ != pharmaCode2DBar6)
327 SetDirty();
328 pharmaCode2DBar6_ = pharmaCode2DBar6;
329 }
330
332
338 {
339 return pharmaCode2DBar6_;
340 };
341
342
344
350 {
351 if(pharmaCode2DBar7_ != pharmaCode2DBar7)
352 SetDirty();
353 pharmaCode2DBar7_ = pharmaCode2DBar7;
354 }
355
357
363 {
364 return pharmaCode2DBar7_;
365 };
366
367
369
375 {
376 if(pharmaCode2DBar8_ != pharmaCode2DBar8)
377 SetDirty();
378 pharmaCode2DBar8_ = pharmaCode2DBar8;
379 }
380
382
388 {
389 return pharmaCode2DBar8_;
390 };
391
392
394
399 void SetPharmaCode2DThreshold(int threshold)
400 {
401 if(threshold < 0 ||
402 threshold > 100)
403 throw std::runtime_error("PharmaCode2DThreshold out of range");
404 if(threshold_ != threshold)
405 SetDirty();
406 threshold_ = static_cast<short>(threshold);
407 }
408
410
416 {
417 return static_cast<int>(threshold_);
418 };
419
420
422
427 void SetPharmaCode2DExpanded(bool expanded)
428 {
429 SetDirty();
430 expanded_ = expanded;
431 }
432
434
440 {
441 return expanded_;
442 };
443
444
446
451 void SetDottedContrast(int contrast)
452 {
453 if(contrast < MinDottedContrastLimit_ ||
454 contrast > MaxDottedContrastLimit_)
455 throw std::runtime_error("Dotted Contrast out of range");
456 if(contrast_ != contrast)
457 SetDirty();
458 contrast_ = static_cast<short>(contrast);
459 }
460
462
467 int DottedContrast() const
468 {
469 return static_cast<int>(contrast_);
470 };
471
472
474
479 void SetDottedModuleWidth(int moduleWidth)
480 {
481 if(moduleWidth < MinDottedModuleWidthLimit_ ||
482 moduleWidth > MaxDottedModuleWidthLimit_)
483 throw std::runtime_error("Dotted module width out of range");
484 if(moduleWidth_ != moduleWidth)
485 SetDirty();
486 moduleWidth_ = static_cast<short>(moduleWidth);
487 }
488
490
496 {
497 return static_cast<int>(moduleWidth_);
498 };
499
500
502
507 void SetDottedQuietzoneWidth(int quietzone)
508 {
509 if(quietzone < MinDottedQuietZoneWidthLimit_ ||
511 throw std::runtime_error("Dotted quietzone width out of range");
512 if(quietzone_ != quietzone)
513 SetDirty();
514 quietzone_ = static_cast<short>(quietzone);
515 }
516
518
524 {
525 return static_cast<int>(quietzone_);
526 };
527
528 protected:
529 DataMatrixLevels levels_;
530 DataMatrixFormats formats_;
531 short minSize_;
532 short maxSize_;
533 SmartBool rectangular_;
534 SmartBool distorted_;
535 DataMatrixSubType subType_;
536 PharmaCode2DDisposition pharmaCode2DBar1_;
537 PharmaCode2DDisposition pharmaCode2DBar2_;
538 PharmaCode2DDisposition pharmaCode2DBar3_;
539 PharmaCode2DDisposition pharmaCode2DBar4_;
540 PharmaCode2DDisposition pharmaCode2DBar5_;
541 PharmaCode2DDisposition pharmaCode2DBar6_;
542 PharmaCode2DDisposition pharmaCode2DBar7_;
543 PharmaCode2DDisposition pharmaCode2DBar8_;
544 short threshold_;
545 SmartBool expanded_;
546 short contrast_;
547 short moduleWidth_;
548 short quietzone_;
549
550
551
552
554 const short MinSizeLimit_ = 7;
555
557 const short MaxSizeLimit_ = 144;
558
560 const short MinDottedContrastLimit_ = 10;
561
563 const short MaxDottedContrastLimit_ = 100;
564
567
569 const short MaxDottedModuleWidthLimit_ = 150;
570
573
576
577
578 public:
579 virtual Symbology Type() const override { return Symbology::DataMatrix; };
580
582
588 static std::unique_ptr<DataMatrix> FromHandle(const HandleGuard<ReaderConfig>& guard, bool& isActiveOut)
589 {
590 auto pConfig = std::unique_ptr<DataMatrix>(new DataMatrix());
591 isActiveOut = pConfig->ReadFromHandle(guard);
592 return pConfig;
593 }
594
595 protected:
596 virtual bool ReadFromHandle_(const HandleGuard<ReaderConfig>& guard) override
597 {
598 unsigned short tmpLevels;
599 unsigned short tmpFormats;
600 short tmpSubType;
601 short tmpBar1;
602 short tmpBar2;
603 short tmpBar3;
604 short tmpBar4;
605 short tmpBar5;
606 short tmpBar6;
607 short tmpBar7;
608 short tmpBar8;
609
610 CVB_CALL_CAPI(CvcBcGetDataMatrixEx(reinterpret_cast<std::intptr_t>(guard.Handle()),
611 &tmpLevels,
612 &tmpFormats,
613 &minSize_,
614 &maxSize_,
615 rectangular_.Ptr(),
616 mirrored_.Ptr(),
617 inverse_.Ptr(),
618 distorted_.Ptr(),
619 &tmpSubType,
620 &tmpBar1,
621 &tmpBar2,
622 &tmpBar3,
623 &tmpBar4,
624 &tmpBar5,
625 &tmpBar6,
626 &tmpBar7,
627 &tmpBar8,
628 &threshold_,
629 expanded_.Ptr(),
630 &contrast_,
631 &moduleWidth_,
632 &quietzone_
633 ));
634 levels_ = static_cast<DataMatrixLevels>(tmpLevels);
635 formats_ = static_cast<DataMatrixFormats>(tmpFormats);
636 subType_ = static_cast<DataMatrixSubType>(tmpSubType);
637 pharmaCode2DBar1_ = static_cast<PharmaCode2DDisposition>(tmpBar1);
638 pharmaCode2DBar2_ = static_cast<PharmaCode2DDisposition>(tmpBar2);
639 pharmaCode2DBar3_ = static_cast<PharmaCode2DDisposition>(tmpBar3);
640 pharmaCode2DBar4_ = static_cast<PharmaCode2DDisposition>(tmpBar4);
641 pharmaCode2DBar5_ = static_cast<PharmaCode2DDisposition>(tmpBar5);
642 pharmaCode2DBar6_ = static_cast<PharmaCode2DDisposition>(tmpBar6);
643 pharmaCode2DBar7_ = static_cast<PharmaCode2DDisposition>(tmpBar7);
644 pharmaCode2DBar8_ = static_cast<PharmaCode2DDisposition>(tmpBar8);
645 return tmpLevels != 0;
646 }
647
648 virtual void WriteToHandle_(bool active, HandleGuard<ReaderConfig>& guard) override
649 {
650 if (!active)
651 levels_ = static_cast<DataMatrixLevels>(0);
652 Internal::DoResCall([&]()
653 {
654 return CVB_CALL_CAPI(CvcBcSetDataMatrixEx(reinterpret_cast<std::intptr_t>(guard.Handle()),
655 static_cast<unsigned short>(levels_),
656 static_cast<unsigned short>(formats_),
657 minSize_,
658 maxSize_,
659 rectangular_,
660 mirrored_,
661 inverse_,
662 distorted_,
663 static_cast<short>(subType_),
664 static_cast<short>(pharmaCode2DBar1_),
665 static_cast<short>(pharmaCode2DBar2_),
666 static_cast<short>(pharmaCode2DBar3_),
667 static_cast<short>(pharmaCode2DBar4_),
668 static_cast<short>(pharmaCode2DBar5_),
669 static_cast<short>(pharmaCode2DBar6_),
670 static_cast<short>(pharmaCode2DBar7_),
671 static_cast<short>(pharmaCode2DBar8_),
672 threshold_,
673 expanded_,
674 contrast_,
675 moduleWidth_,
676 quietzone_
677 ));
678 });
679 }
680 protected:
681 DataMatrix()
682 : Reader2DConfigBase()
683 {
684 }
685
686 };
687
688 using DataMatrixPtr = std::shared_ptr<DataMatrix>;
689 }
690
691 CVB_END_INLINE_NS
692}
Configuration to access parameters of Reader2DConfigBase.
Definition: reader_2d_config_base.hpp:19
Configuration to access parameters of DataMatrix.
Definition: data_matrix.hpp:18
int MaxSize() const
Returns the maximum number of lines and columns.
Definition: data_matrix.hpp:112
void SetLevels(DataMatrixLevels levels)
Bit field which specifies the permitted error correction level (ECCs).
Definition: data_matrix.hpp:26
DataMatrixFormats Formats() const
Bit field which specifies the permitted coding schemes (also known as format IDs) (only for ECC 000 t...
Definition: data_matrix.hpp:57
void SetPharmaCode2DBar8(PharmaCode2DDisposition pharmaCode2DBar8)
Proofing of the color bar of field 8 on square or rectangular (2D Pharma Codes only)
Definition: data_matrix.hpp:374
int PharmaCode2DThreshold() const
Returns the minimum digitalisation threshold of the colour bars in percent (only for 2D Pharmacode) r...
Definition: data_matrix.hpp:415
void SetDottedModuleWidth(int moduleWidth)
The module width of the code (only dotted Data Matrix).
Definition: data_matrix.hpp:479
int DottedModuleWidth() const
Returns the module width of the code (only dotted Data Matrix).
Definition: data_matrix.hpp:495
bool AllowDistorted() const
Returns whether the code is distorted (no effect with dotted Data Matrix).
Definition: data_matrix.hpp:162
void SetDottedQuietzoneWidth(int quietzone)
Quiet zone around the code (only dotted Data Matrix).
Definition: data_matrix.hpp:507
void SetAllowDistorted(bool distorted)
Code is distorted (no effect with dotted Data Matrix).
Definition: data_matrix.hpp:150
int DottedQuietzoneWidth() const
Returns the quiet zone around the code (only dotted Data Matrix).
Definition: data_matrix.hpp:523
PharmaCode2DDisposition PharmaCode2DBar8() const
Returns the proofing of the color bar of field 8 on square or rectangular (2D Pharma Codes only)
Definition: data_matrix.hpp:387
void SetPharmaCode2DBar5(PharmaCode2DDisposition pharmaCode2DBar5)
Proofing of the color bar of field 5 on square or rectangular (2D Pharma Codes only)
Definition: data_matrix.hpp:299
PharmaCode2DDisposition PharmaCode2DBar4() const
Returns the proofing of the color bar of field 4 on square or rectangular (2D Pharma Codes only)
Definition: data_matrix.hpp:287
void SetPharmaCode2DBar4(PharmaCode2DDisposition pharmaCode2DBar4)
Proofing of the color bar of field 4 on square or rectangular (2D Pharma Codes only)
Definition: data_matrix.hpp:274
static std::unique_ptr< DataMatrix > FromHandle(const HandleGuard< ReaderConfig > &guard, bool &isActiveOut)
Create object from handle.
Definition: data_matrix.hpp:588
const short MinDottedModuleWidthLimit_
Lowest possible dotted module width value.
Definition: data_matrix.hpp:566
const short MinDottedContrastLimit_
Lowest possible dotted contrast value.
Definition: data_matrix.hpp:560
const short MinSizeLimit_
Lowest possible number of rows/columns in a data matrix code.
Definition: data_matrix.hpp:554
void SetPharmaCode2DExpanded(bool expanded)
Specifies whether the code is expanded or not(only for 2D Pharmacode).
Definition: data_matrix.hpp:427
const short MinDottedQuietZoneWidthLimit_
Minimum quiet zone width when reading dotted data matrix codes.
Definition: data_matrix.hpp:572
PharmaCode2DDisposition PharmaCode2DBar3() const
Returns the proofing of the color bar of field 3 on square or rectangular (2D Pharma Codes only)
Definition: data_matrix.hpp:262
int MinSize() const
Returns the minimum number of lines and columns.
Definition: data_matrix.hpp:84
void SetSubType(DataMatrixSubType subType)
Distinguish between evaluate characteristics of the Data Matrix code (DataMatrixSubType::DataMatrix,...
Definition: data_matrix.hpp:174
void SetPharmaCode2DBar2(PharmaCode2DDisposition pharmaCode2DBar2)
Proofing of the color bar of field 2 on square or rectangular (2D Pharma Codes only)
Definition: data_matrix.hpp:224
void SetAllowRectangular(bool rectangular)
Permit/do not permit rectangular Data Matrix.
Definition: data_matrix.hpp:123
const short MaxSizeLimit_
Highest possible number of rows/columns in a data matrix code.
Definition: data_matrix.hpp:557
PharmaCode2DDisposition PharmaCode2DBar1() const
Returns the proofing of the color bar of field 1 on square or rectangular (2D Pharma Codes only)
Definition: data_matrix.hpp:212
void SetPharmaCode2DBar7(PharmaCode2DDisposition pharmaCode2DBar7)
Proofing of the color bar of field 7 on square or rectangular (2D Pharma Codes only)
Definition: data_matrix.hpp:349
DataMatrixSubType SubType() const
Returns the evaluate characteristics of the Data Matrix code (DataMatrixSubType::DataMatrix,...
Definition: data_matrix.hpp:187
PharmaCode2DDisposition PharmaCode2DBar6() const
Returns the proofing of the color bar of field 6 on square or rectangular (2D Pharma Codes only)
Definition: data_matrix.hpp:337
PharmaCode2DDisposition PharmaCode2DBar5() const
Returns the proofing of the color bar of field 5 on square or rectangular (2D Pharma Codes only)
Definition: data_matrix.hpp:312
void SetPharmaCode2DBar1(PharmaCode2DDisposition pharmaCode2DBar1)
Proofing of the color bar of field 1 on square or rectangular (2D Pharma Codes only)
Definition: data_matrix.hpp:199
void SetPharmaCode2DThreshold(int threshold)
Minimum digitalisation threshold of the colour bars in percent (only for 2D Pharmacode) ranging from ...
Definition: data_matrix.hpp:399
void SetMaxSize(int maxSize)
Maximum number of lines and columns.
Definition: data_matrix.hpp:96
int DottedContrast() const
Returns the minimal contrast value of the code (only dotted Data Matrix).
Definition: data_matrix.hpp:467
PharmaCode2DDisposition PharmaCode2DBar2() const
Returns the proofing of the color bar of field 2 on square or rectangular (2D Pharma Codes only)
Definition: data_matrix.hpp:237
PharmaCode2DDisposition PharmaCode2DBar7() const
Returns the proofing of the color bar of field 7 on square or rectangular (2D Pharma Codes only)
Definition: data_matrix.hpp:362
const short MaxDottedModuleWidthLimit_
Highest possible dotted module width value.
Definition: data_matrix.hpp:569
const short MaxDottedContrastLimit_
Highest possible dotted contrast value.
Definition: data_matrix.hpp:563
void SetDottedContrast(int contrast)
Minimal contrast value of the code (only dotted Data Matrix).
Definition: data_matrix.hpp:451
void SetMinSize(int minSize)
Minimum number of lines and columns.
Definition: data_matrix.hpp:68
void SetPharmaCode2DBar3(PharmaCode2DDisposition pharmaCode2DBar3)
Proofing of the color bar of field 3 on square or rectangular (2D Pharma Codes only)
Definition: data_matrix.hpp:249
bool AllowRectangular() const
Returns whether to permit/not permit rectangular Data Matrix.
Definition: data_matrix.hpp:135
const short MaxDottedQuietZoneWidthLimit_
Maximum quiet zone width when reading dotted data matrix codes.
Definition: data_matrix.hpp:575
void SetFormats(DataMatrixFormats formats)
Bit field which specifies the permitted coding schemes (also known as format IDs) (only for ECC 000 t...
Definition: data_matrix.hpp:44
void SetPharmaCode2DBar6(PharmaCode2DDisposition pharmaCode2DBar6)
Proofing of the color bar of field 6 on square or rectangular (2D Pharma Codes only)
Definition: data_matrix.hpp:324
bool PharmaCode2DExpanded() const
Returns whether the code is expanded or not(only for 2D Pharmacode).
Definition: data_matrix.hpp:439
Symbology
The symbologies supported by Barcode.
Definition: barcode.hpp:97
@ DataMatrix
Data Matrix Code.
PharmaCode2DDisposition
Expectation setting for Pharma Code 2D elements.
Definition: barcode.hpp:360
DataMatrixLevels
Levels of DataMatrix codes to recognize. Different levels may be combined using '|'.
Definition: barcode.hpp:295
DataMatrixSubType
Sub types of data matrix codes to read.
Definition: barcode.hpp:334
DataMatrixFormats
Formats of DataMatrix codes to recognize. Different formats may be combined using '|'.
Definition: barcode.hpp:315
Root namespace for the Image Manager interface.
Definition: c_barcode.h:24