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
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078 #ifndef INC_GRE_LABELPLACEMENT_H
00079 #define INC_GRE_LABELPLACEMENT_H
00080
00081
00082 #ifndef INC_RVC_ELEMENT_H
00083 #include <rvc/element.h>
00084 #endif
00085
00086 #ifndef INC_MI32_REGION2D_H
00087 #include <mi32/region2d.h>
00088 #endif
00089
00090 #ifndef INC_MI32_ELEMSTYL_H
00091 #include <mi32/elemstyl.h>
00092 #endif
00093
00094 #ifndef INC_MI32_TEXTBASE_H
00095 #include <mi32/textbase.h>
00096 #endif
00097
00098 #ifndef INC_MI32_QTREE_H
00099 #include <mi32/qtree.h>
00100 #endif
00101
00102 #ifndef INC_RVC_STYLE_H
00103 #include <rvc/style.h>
00104 #endif
00105
00106
00107 class LABELSTYLE;
00108 class GRE_LAYER;
00109 class GRE_LAYERDC;
00110 class GRE_VIEW;
00111 class QUADTREE;
00112 struct LINESTYLE;
00113
00114 namespace MGD {
00115 class CONTEXT;
00116 }
00117
00118 namespace GRE {
00119 class LABELPLACEMENT;
00120
00121 class LABELATTACHMENT {
00122 public:
00123
00124 LABELATTACHMENT (
00125 ) { }
00126
00127
00128 LABELATTACHMENT (
00129 const RVC::ELEMENT& elem
00130 ) :
00131 m_elem(elem)
00132 {
00133 }
00134
00135
00136 LABELATTACHMENT (
00137 const LABELATTACHMENT& rhs
00138 ) :
00139 m_elem(rhs.m_elem),
00140 m_leader(rhs.m_leader)
00141 {
00142 }
00143
00144
00145 LABELATTACHMENT (
00146 const RVC::ELEMENT& elem,
00147 const POLYLINE& leader
00148 ) :
00149 m_elem(elem),
00150 m_leader(leader)
00151 {
00152 }
00153
00154 ~LABELATTACHMENT() {}
00155
00156 const RVC::ELEMENT& GetElement (
00157 ) const {
00158 return (m_elem);
00159 }
00160
00161 const POLYLINE& GetLeader (
00162 ) const {
00163 return (m_leader);
00164 }
00165
00166 void SetElement (
00167 const RVC::ELEMENT& elem
00168 ) {
00169 m_elem = elem;
00170 }
00171
00172 void SetLeader (
00173 const POLYLINE& leader
00174 ) {
00175 m_leader = leader;
00176 }
00177
00178 private:
00179 RVC::ELEMENT m_elem;
00180 POLYLINE m_leader;
00181
00182 };
00183
00184
00185
00186
00187
00188
00189
00190 class LABELPLACE {
00191 public:
00192
00193 LABELPLACE();
00194
00195
00196 LABELPLACE (
00197 const LABELPLACE& rhs
00198 );
00199
00200
00201 ~LABELPLACE();
00202
00203
00204 LABELPLACE& operator=(
00205 const LABELPLACE& rhs
00206 );
00207
00208
00209
00210
00211 void ComputeLabelExtents (
00212 MGD::CONTEXT* gc,
00213 REGION2D& region,
00214 bool bIgnoreLeaders = false
00215 ) const;
00216
00217
00218 void DeleteAttachment (
00219 const RVC::ELEMENT& element
00220 );
00221
00222
00223
00224
00225
00226 void Detach (
00227 );
00228
00229
00230 ERRVALUE Draw (
00231 GRE_LAYERDC* pDC,
00232 const COLOR* ForegroundColor = 0
00233 ) const;
00234
00235
00236 ERRVALUE DrawSample (
00237 MGD::CONTEXT& gc,
00238 const COLOR* ForegroundColor = 0,
00239 bool bDrawLeaders = true
00240 ) const;
00241
00242
00243 const MILIST<LABELATTACHMENT>& GetAttachments (
00244 ) const;
00245
00246 double GetBaseAngle (
00247 ) const;
00248
00249 const POLYLINE& GetBaseLine (
00250 ) const;
00251
00252 TEXTBASEORIGIN GetBaseOrigin (
00253 ) const;
00254
00255 const DPOINT2D& GetBasePoint (
00256 ) const;
00257
00258 bool GetDrawBaseLine (
00259 ) const;
00260
00261
00262
00263 bool GetBaseLineStyle (
00264 LINESTYLE&
00265 ) const;
00266
00267
00268
00269
00270 GRE_LAYER* GetLayer (
00271 ) const;
00272
00273
00274
00275 const DPOINT2D& GetOffset (
00276 ) const;
00277
00278
00279
00280 const DPOINT2D& GetSymbolPoint (
00281 ) const;
00282
00283
00284 const POINTSTYLE& GetPointStyle (
00285 ) const;
00286
00287
00288 const SIMPLE_ARRAY<UINT8>& GetPointSymbol (
00289 ) const;
00290
00291
00292
00293 double GetPriority (
00294 ) const;
00295
00296
00297 const REGION2D& GetRegion (
00298 ) const;
00299
00300 const LABELSTYLE& GetStyle (
00301 ) const;
00302
00303 const MISTRING& GetText (
00304 ) const;
00305
00306
00307 bool HasPoint (
00308 ) const;
00309
00310
00311 bool HasText (
00312 ) const;
00313
00314
00315 bool IsAttached (
00316 ELEMTYPE ElemType,
00317 INT32 ElemNum
00318 ) const;
00319
00320
00321 bool IsAttached (
00322 const RVC::ELEMENT& elem
00323 ) const;
00324
00325
00326
00327 bool IsLocked (
00328 ) const;
00329
00330
00331
00332 void LockPosition (
00333 bool locked = true
00334 );
00335
00336
00337 void Move (
00338 const DPOINT2D& delta
00339 );
00340
00341
00342 void AddAttachment (
00343 const LABELATTACHMENT& attachment
00344 );
00345
00346
00347 void AddAttachment (
00348 const RVC::ELEMENT& element
00349 );
00350
00351 void SetBaseLine (
00352 const POLYLINE& baseline
00353 );
00354
00355 void SetBaseLine (
00356 const DPOINT2D& pt,
00357 double angle,
00358 TEXTBASEORIGIN origin
00359 );
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369 void SetCopyOnWrite (
00370 bool bCopyOnWrite = true
00371 ) {
00372 m_bCopyOnWrite = bCopyOnWrite;
00373 }
00374
00375 void SetDrawBaseLine (
00376 bool draw = true
00377 );
00378
00379
00380 void SetBaseLineStyle (
00381 const LINESTYLE& style
00382 );
00383
00384
00385
00386 void SetPoint (
00387 const DPOINT2D& location
00388 );
00389
00390
00391 void SetPointStyle (
00392 const POINTSTYLE& style
00393 );
00394
00395
00396 void SetPointSymbol (
00397 const SIMPLE_ARRAY<UINT8>& symbol
00398 );
00399
00400
00401 void SetPointSymbol (
00402 const RVC::STYLE::SYMBOLPATTERN& symbol
00403 );
00404
00405
00406
00407 void SetPriority (
00408 double priority
00409 );
00410
00411
00412 void SetRegion (
00413 const REGION2D& region
00414 );
00415
00416 void SetStyle (
00417 const LABELSTYLE& style
00418 );
00419
00420 void SetText (
00421 const MISTRING& str
00422 );
00423
00424 #if !defined(GENERATING_DOXYGEN_OUTPUT)
00425
00426 void SetParent (
00427 GRE::LABELPLACEMENT* parent
00428 );
00429
00430 GRE::LABELPLACEMENT* GetParent (
00431 ) const;
00432
00433
00434
00435
00436
00437
00438 const MIUNICODE* GetUserString (
00439 ) const;
00440
00441
00442
00443
00444
00445 void SetUserString (
00446 const MISTRING& str
00447 );
00448
00449 void Zoom (
00450 double scale
00451 );
00452
00453
00454
00455 void SetID (
00456 INT32 id
00457 );
00458 #endif
00459
00460 private:
00461
00462 class PRIV;
00463 PRIV *m_priv;
00464 bool m_bCopyOnWrite;
00465 };
00466
00467
00468
00469
00470 class LABELPLACEMENT {
00471 public:
00472 class ITERATOR;
00473 class CONST_ITERATOR;
00474 friend class CONST_ITERATOR;
00475
00476 class CONST_ITERATOR {
00477 public:
00478
00479
00480 CONST_ITERATOR (
00481 ) :
00482 m_placement(0),
00483 m_num(-1)
00484 { }
00485
00486
00487 virtual ~CONST_ITERATOR() {};
00488
00489
00490 CONST_ITERATOR (
00491 const CONST_ITERATOR& rhs
00492 ) :
00493 m_placement(rhs.m_placement),
00494 m_place(rhs.m_place),
00495 m_num(rhs.m_num)
00496 {}
00497
00498
00499
00500 CONST_ITERATOR (
00501 LABELPLACEMENT* placement
00502 ) :
00503 m_placement(placement),
00504 m_num(-1)
00505 {
00506 ReadNext(true);
00507 }
00508
00509
00510 const LABELPLACE& operator* (
00511 ) const { return (m_place); }
00512
00513
00514 const LABELPLACE* operator-> (
00515 ) const { return (&**this); }
00516
00517
00518 CONST_ITERATOR& operator++(
00519 ) {
00520 ReadNext(true);
00521 return *this;
00522 }
00523
00524
00525 CONST_ITERATOR operator++(int
00526 ) {
00527 CONST_ITERATOR temp = *this;
00528 ++*this;
00529 return(temp);
00530 }
00531
00532
00533 CONST_ITERATOR& operator--(
00534 ) {
00535 ReadPrev(true);
00536 return *this;
00537 }
00538
00539
00540 CONST_ITERATOR operator--(int
00541 ) {
00542 CONST_ITERATOR temp = *this;
00543 --*this;
00544 return(temp);
00545 }
00546
00547
00548 bool operator== (
00549 const CONST_ITERATOR& rhs
00550 ) const {
00551 if (m_num == -1 && rhs.m_num == -1) return (true);
00552 return (m_num == rhs.m_num && m_placement == rhs.m_placement);
00553 }
00554
00555
00556 bool operator!= (
00557 const CONST_ITERATOR& rhs
00558 ) const { return (!(*this == rhs)); }
00559
00560 #if !defined(GENERATING_DOXYGEN_OUTPUT)
00561 protected:
00562 LABELPLACEMENT* m_placement;
00563 LABELPLACE m_place;
00564 int m_num;
00565 void ReadPrev (bool bIsConst);
00566 void ReadNext (bool bIsConst);
00567 #endif
00568 };
00569
00570 friend class ITERATOR;
00571 class ITERATOR : public CONST_ITERATOR {
00572 public:
00573 ITERATOR();
00574
00575
00576 ITERATOR(LABELPLACEMENT* placement) :
00577 CONST_ITERATOR(placement)
00578 { }
00579
00580
00581 LABELPLACE& operator* (
00582 ) { return (m_place); }
00583
00584
00585 LABELPLACE* operator-> (
00586 ) { return (&**this); }
00587
00588
00589 ITERATOR& operator++() {
00590 ReadNext(false);
00591 return (*this);
00592 }
00593
00594
00595 ITERATOR operator++(int
00596 ) {
00597 ITERATOR temp = *this;
00598 ++*this;
00599 return(temp);
00600 }
00601
00602
00603 ITERATOR& operator--() {
00604 ReadPrev(false);
00605 return (*this);
00606 };
00607
00608
00609 ITERATOR operator--(int
00610 ) {
00611 ITERATOR temp = *this;
00612 --*this;
00613 return(temp);
00614 }
00615
00616
00617 bool operator== (
00618 const ITERATOR& rhs
00619 ) const;
00620
00621
00622 bool operator!= (
00623 const ITERATOR& rhs
00624 ) const { return (!(*this == rhs)); }
00625 };
00626
00627
00628
00629 static ERRVALUE Deconflict (
00630 SIMPLE_ARRAY<LABELPLACEMENT*>& LabelSets
00631 );
00632
00633
00634 LABELPLACEMENT (
00635 GRE_LAYER* layer,
00636 GRE_VIEW* view
00637 );
00638
00639
00640 virtual ~LABELPLACEMENT (
00641 );
00642
00643
00644 ERRVALUE Add (
00645 const LABELPLACE& place
00646 );
00647
00648
00649 CONST_ITERATOR Begin (
00650 ) const { return (CONST_ITERATOR(const_cast<LABELPLACEMENT*>(this))); }
00651
00652
00653 void Clear (
00654 );
00655
00656
00657
00658
00659 void DeleteLabels (
00660 const RVC::ELEMENT& element
00661 );
00662
00663
00664 CONST_ITERATOR End (
00665 ) const { return (CONST_ITERATOR(0)); }
00666
00667
00668
00669
00670
00671
00672
00673
00674
00675 INT32 Find (
00676 const DPOINT2D& pt,
00677 GRE::LABELPLACE& place,
00678 int maxdist = 0
00679 ) const;
00680
00681
00682
00683
00684
00685 INT32 Find (
00686 const DPOINT2D& pt,
00687 MILIST<GRE::LABELPLACE*>& list,
00688 int maxdist = 0
00689 ) const;
00690
00691
00692
00693
00694
00695 INT32 Find (
00696 const DRECT2D& rect,
00697 MILIST<GRE::LABELPLACE*>& list
00698 ) const;
00699
00700
00701
00702
00703
00704
00705 INT32 Find (
00706 const REGION2D& region,
00707 MILIST<GRE::LABELPLACE*>& list
00708 ) const;
00709
00710
00711
00712
00713
00714
00715
00716
00717
00718 ERRVALUE GetCombinedRegion (
00719 REGION2D& region,
00720 bool bClear = true
00721 ) const;
00722
00723
00724
00725 bool GetLabelPlace (
00726 const RVC::ELEMENT& elem,
00727 GRE::LABELPLACE& place
00728 ) const;
00729
00730
00731
00732 bool GetLabelPlaces (
00733 const RVC::ELEMENT& elem,
00734 MILIST<GRE::LABELPLACE>& places
00735 ) const;
00736
00737 GRE_LAYER* GetLayer (
00738 ) const;
00739
00740 int GetNumItems (
00741 ) const;
00742
00743 GRE_VIEW* GetView (
00744 ) const;
00745
00746 private:
00747
00748
00749
00750
00751
00752
00753
00754 virtual bool v_CompareLabels (
00755 const RVC::ELEMENT& elem1,
00756 const RVC::ELEMENT& elem2
00757 ) const;
00758
00759 #if !defined(GENERATING_DOXYGEN_OUTPUT)
00760 class PRIV;
00761 PRIV* m_priv;
00762
00763 protected:
00764
00765 GRE::LABELPLACE* GetItem (
00766 int num
00767 );
00768 public:
00769
00770 QUADTREE& GetQuadTree();
00771
00772 #endif
00773 };
00774
00775
00776 }
00777
00778
00779 #endif
00780