00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef INC_GRE_LEGEND_H
00016 #define INC_GRE_LEGEND_H
00017
00018 #ifndef INC_RVC_DBELEM_H
00019 #include <rvc/dbelem.h>
00020 #endif
00021
00022 #ifndef INC_GRE_ELEMSAMPLEDC_H
00023 #include <gre/elemsampledc.h>
00024 #endif
00025
00026
00027
00028 #define GRE_LEGENDVIEW_LabelSpace 4
00029 #define GRE_LEGENDVIEW_ItemSpace 2
00030
00031
00032 class GRE_LEGEND {
00033 public:
00034
00035 class DRAWCONTEXT;
00036 class ITEMBASE;
00037 typedef MILIST<ITEMBASE*> ITEMLIST;
00038
00039
00040 explicit GRE_LEGEND (
00041 GRE_LAYER *layer,
00042 ELEMTYPE ElemType
00043 );
00044
00045
00046 virtual ~GRE_LEGEND (
00047 );
00048
00049 #if defined(X_NATIVE) || defined(WIN32_MFC)
00050
00051 virtual ERRVALUE AddElemPrompted (
00052 MDLGPARENT dlgparent,
00053 const RVC::ELEMENT& element
00054 );
00055 #endif
00056
00057
00058 bool ContainsElem (
00059 const RVC::ELEMENT& element
00060 ) const;
00061
00062
00063 ERRVALUE CreateElemTable (
00064 const RVC::OBJECTNAME& TableName,
00065 const RVC::OBJECTDESC& TableDesc
00066 );
00067
00068
00069 void DeleteAllItems (
00070 );
00071
00072
00073 ERRVALUE DeleteElem (
00074 const RVC::ELEMENT& element
00075 );
00076
00077
00078 void Draw (
00079 const DRAWCONTEXT& dc,
00080 LPOINT2D& origin
00081 ) const;
00082
00083
00084 ELEMTYPE GetElemType (
00085 ) const { return (m_ElemType); }
00086
00087
00088 const ITEMLIST& GetItemList (
00089 ) const { return (m_ItemList); }
00090
00091
00092 virtual void GetItemSizeMM (
00093 DPOINT2D& size
00094 ) const;
00095
00096
00097
00098 virtual void GetItemSizePixels (
00099 LPOINT2D& size
00100 ) const;
00101
00102
00103 GRE_LAYER* GetLayer (
00104 ) const { return (m_layer); }
00105
00106
00107
00108 MGD::STYLESAMPLEFLAGS GetSampleFlags (
00109 ) const { return (m_SampleFlags); }
00110
00111
00112
00113 LPOINT2D GetSize (
00114 const DRAWCONTEXT& dc
00115 ) const;
00116
00117
00118 const RVC::OBJITEM& GetStyleObjItem (
00119 ) { return (m_StyleObjItem); }
00120
00121
00122 bool HasElemTable (
00123 ) const { return (m_ElemTable.IsAttached()); }
00124
00125
00126 bool HasItems (
00127 ) const { return (!m_ItemList.IsEmpty()); }
00128
00129
00130 bool IsMergingDuplicateStyles (
00131 ) const { return (m_MergeDupStyles); }
00132
00133
00134 bool IsSorted (
00135 ) const { return (m_Sorted); }
00136
00137
00138 void SetMergeDuplicateStyles (
00139 bool MergeDupStyles = true
00140 ) { m_MergeDupStyles = MergeDupStyles; }
00141
00142
00143 void SetNeedStyleObject (
00144 bool NeedStyleObj = true
00145 ) { m_NeedStyleObj = NeedStyleObj; }
00146
00147
00148 void SetSampleFlags (
00149 MGD::STYLESAMPLEFLAGS newflags
00150 ) { m_SampleFlags = newflags | MGD::STYLESAMPLE_ShrinkToFit; }
00151
00152
00153
00154 void SetSorted (
00155 bool sorted = true
00156 ) { m_Sorted = sorted; }
00157
00158
00159 void SetStyleObject (
00160 const RVC::OBJITEM& StyleObj
00161 );
00162
00163 protected:
00164
00165 ITEMLIST m_ItemList;
00166 RVC::OBJITEM m_GeoObjItem;
00167 RVC::DBASE_ELEMENT m_DbObject;
00168 RVC::DBTABLE m_ElemTable;
00169
00170 ERRVALUE AddElemRecord (
00171 const RVC::ELEMENT& element,
00172 const MISTRING& prilabel,
00173 const MISTRING& seclabel
00174 );
00175
00176 void InsertItem (
00177 ITEMBASE *item
00178 );
00179
00180 ERRVALUE OpenElemTable (
00181 const RVC::OBJECTNAME& ElemTableName
00182 );
00183
00184 ERRVALUE OpenStyle (
00185 RVC::DBTABLE_STYLE& StyleTable,
00186 const RVC::OBJITEM& StyleObjItem,
00187 const RVC::OBJITEM& GeoObjItem,
00188 RVC::STYLE& StyleObj
00189 );
00190
00191 void SetHasMergedStyles (
00192 ) { m_HasMergedStyles = true; }
00193
00194 private:
00195 #ifndef GENERATING_DOXYGEN_OUTPUT
00196 GRE_LAYER *m_layer;
00197 ELEMTYPE m_ElemType;
00198 bool m_Sorted;
00199 bool m_NeedStyleObj;
00200 bool m_MergeDupStyles;
00201 bool m_HasMergedStyles;
00202 MGD::STYLESAMPLEFLAGS m_SampleFlags;
00203 RVC::OBJITEM m_StyleObjItem;
00204
00205 GRE_LEGEND (const GRE_LEGEND&);
00206 GRE_LEGEND& operator= (const GRE_LEGEND&);
00207
00208 friend class DRAWCONTEXT;
00209 #endif // GENERATING_DOXYGEN_OUTPUT
00210 };
00211
00212
00213
00214 class GRE_LEGEND::DRAWCONTEXT : public GRE_ELEMSAMPLE_DC {
00215 public:
00216
00217
00218
00219 enum ORIENTATION {
00220 ORIENTATION_Vertical = 0,
00221 ORIENTATION_Horizonatal = 1
00222 };
00223
00224 GRE_LAYER *m_layer;
00225 ELEMTYPE m_ElemType;
00226 INT32 m_itemheight;
00227 INT32 m_samplewidth;
00228 INT32 m_labelspace;
00229 INT32 m_itemspace;
00230 LRECT2D m_cliprect;
00231 bool m_DrawLabels;
00232 bool m_DrawLabelsOnColorScales;
00233 bool m_HasTextStyle;
00234 TEXTSTYLE m_TextStyle;
00235 ORIENTATION m_Orientation;
00236
00237
00238 DRAWCONTEXT (
00239 const GRE_LEGEND& legend,
00240 MGD::CONTEXT *gc,
00241 INT32 labelspace,
00242 INT32 itemspace,
00243 const LRECT2D& cliprect
00244 );
00245
00246 virtual ~DRAWCONTEXT (
00247 );
00248
00249
00250 bool IsVertical (
00251 ) const { return (m_Orientation == ORIENTATION_Vertical); }
00252
00253
00254 void SetDrawLabels (
00255 bool DrawLabels
00256 ) { m_DrawLabels = DrawLabels; }
00257
00258 };
00259
00260
00261
00262 class GRE_LEGEND::ITEMBASE {
00263 public:
00264
00265
00266 ITEMBASE (
00267 );
00268
00269
00270 explicit ITEMBASE (
00271 const MISTRING& label
00272 );
00273
00274
00275 ITEMBASE (
00276 const RVC::ELEMENT& element,
00277 const MISTRING& label
00278 );
00279
00280
00281 virtual ~ITEMBASE (
00282 );
00283
00284
00285 virtual void Draw (
00286 const DRAWCONTEXT& dc,
00287 const LRECT2D& samplerect
00288 ) const = 0;
00289
00290
00291 void DrawLabel (
00292 const DRAWCONTEXT& dc,
00293 const LRECT2D& samplerect
00294 ) const;
00295
00296 #ifdef WIN32_MFC
00297
00298
00299 virtual void DrawTreeView (
00300 void *hdc,
00301 const GRE_ELEMSAMPLE_DC& dc,
00302 const CRect& rect,
00303 bool HasFocus
00304 ) = 0;
00305 #endif
00306
00307
00308 const RVC::ELEMENT& GetElement (
00309 ) const { return (m_element); }
00310
00311
00312 INT32 GetElemNum (
00313 ) const { return (m_element.GetNumber()); }
00314
00315
00316 const MISTRING& GetLabel (
00317 ) const { return (m_label); }
00318
00319
00320 void GetLabelSize (
00321 const DRAWCONTEXT& dc,
00322 LPOINT2D& size
00323 ) const;
00324
00325
00326 virtual bool HasTransparency (
00327 ) const;
00328
00329
00330 void MergeLabel (
00331 const MISTRING& label
00332 );
00333
00334 private:
00335 #ifndef GENERATING_DOXYGEN_OUTPUT
00336 RVC::ELEMENT m_element;
00337 MISTRING m_label;
00338
00339 ITEMBASE (const ITEMBASE&);
00340 ITEMBASE& operator= (const ITEMBASE&);
00341 #endif
00342 };
00343
00344
00345
00346
00347
00348 class GRE_LEGEND_POINT : public GRE_LEGEND {
00349 public:
00350
00351 class ITEM;
00352
00353
00354 GRE_LEGEND_POINT (
00355 GRE_LAYER *layer,
00356 ELEMTYPE ElemType
00357 );
00358
00359 #if defined(X_NATIVE) || defined(WIN32_MFC)
00360
00361 virtual ERRVALUE AddElemPrompted (
00362 MDLGPARENT dlgparent,
00363 const RVC::ELEMENT& element
00364 );
00365 #endif
00366
00367
00368 void AddItem (
00369 const POINTSTYLE& style,
00370 const MISTRING& label
00371 );
00372
00373
00374 void AddItem (
00375 const RVC::ELEMENT& element,
00376 const MISTRING& label
00377 );
00378
00379 ERRVALUE Setup (
00380 const POINTPARMS& parms,
00381 const RVC::OBJITEM& GeoObjItem,
00382 const RVC::OBJITEM& StyleObjItem
00383 );
00384
00385 private:
00386 #ifndef GENERATING_DOXYGEN_OUTPUT
00387 GRE_LEGEND_POINT (const GRE_LEGEND_POINT&);
00388 GRE_LEGEND_POINT& operator= (const GRE_LEGEND_POINT&);
00389 #endif // GENERATING_DOXYGEN_OUTPUT
00390 };
00391
00392
00393
00394 class GRE_LEGEND_POINT::ITEM : public GRE_LEGEND::ITEMBASE {
00395 public:
00396
00397
00398 ITEM (
00399 const POINTSTYLE& style,
00400 const MISTRING& label
00401 );
00402
00403
00404 ITEM (
00405 const RVC::ELEMENT& element,
00406 const MISTRING& label
00407 );
00408
00409
00410 virtual ~ITEM (
00411 );
00412
00413
00414 virtual void Draw (
00415 const DRAWCONTEXT& dc,
00416 const LRECT2D& samplerect
00417 ) const;
00418
00419 #ifdef WIN32_MFC
00420
00421 virtual void DrawTreeView (
00422 void *hdc,
00423 const GRE_ELEMSAMPLE_DC& dc,
00424 const CRect& rect,
00425 bool HasFocus
00426 );
00427 #endif
00428
00429
00430 const POINTSTYLE& GetStyle (
00431 ) const { return (m_style); }
00432
00433
00434 bool HasSameStyle (
00435 const POINTSTYLE& style
00436 ) const;
00437
00438
00439 virtual bool HasTransparency (
00440 ) const;
00441
00442 private:
00443 #ifndef GENERATING_DOXYGEN_OUTPUT
00444 POINTSTYLE m_style;
00445 ITEM (const ITEM&);
00446 ITEM& operator= (const ITEM&);
00447 #endif
00448 };
00449
00450
00451
00452
00453
00454 class GRE_LEGEND_LINE : public GRE_LEGEND {
00455 public:
00456
00457 class ITEM;
00458
00459
00460 GRE_LEGEND_LINE (
00461 GRE_LAYER *layer,
00462 ELEMTYPE ElemType
00463 );
00464
00465 #if defined(X_NATIVE) || defined(WIN32_MFC)
00466
00467 virtual ERRVALUE AddElemPrompted (
00468 MDLGPARENT dlgparent,
00469 const RVC::ELEMENT& element
00470 );
00471 #endif
00472
00473
00474 void AddItem (
00475 const LINESTYLE& style,
00476 const MISTRING& label
00477 );
00478
00479
00480 void AddItem (
00481 const RVC::ELEMENT& element,
00482 const MISTRING& label
00483 );
00484
00485 ERRVALUE Setup (
00486 const LINEPARMS& parm,
00487 const RVC::OBJITEM& GeoObjItem,
00488 const RVC::OBJITEM& StyleObjItem
00489 );
00490
00491 private:
00492 #ifndef GENERATING_DOXYGEN_OUTPUT
00493 GRE_LEGEND_LINE (const GRE_LEGEND_LINE&);
00494 GRE_LEGEND_LINE& operator= (const GRE_LEGEND_LINE&);
00495 #endif // GENERATING_DOXYGEN_OUTPUT
00496 };
00497
00498
00499 class GRE_LEGEND_LINE::ITEM : public GRE_LEGEND::ITEMBASE {
00500 public:
00501
00502
00503 ITEM (
00504 const LINESTYLE& style,
00505 const MISTRING& label
00506 );
00507
00508
00509 ITEM (
00510 const RVC::ELEMENT& element,
00511 const MISTRING& label
00512 );
00513
00514
00515 virtual ~ITEM (
00516 );
00517
00518
00519 virtual void Draw (
00520 const DRAWCONTEXT& dc,
00521 const LRECT2D& samplerect
00522 ) const;
00523
00524 #ifdef WIN32_MFC
00525
00526 virtual void DrawTreeView (
00527 void *hdc,
00528 const GRE_ELEMSAMPLE_DC& dc,
00529 const CRect& rect,
00530 bool HasFocus
00531 );
00532 #endif
00533
00534
00535 const LINESTYLE& GetStyle (
00536 ) const { return (m_style); };
00537
00538
00539 bool HasSameStyle (
00540 const LINESTYLE& style
00541 ) const;
00542
00543
00544 virtual bool HasTransparency (
00545 ) const;
00546
00547 private:
00548 #ifndef GENERATING_DOXYGEN_OUTPUT
00549 LINESTYLE m_style;
00550 ITEM (const ITEM&);
00551 ITEM& operator= (const ITEM&);
00552 #endif
00553 };
00554
00555
00556
00557
00558 class GRE_LEGEND_POLY : public GRE_LEGEND {
00559 public:
00560
00561 class ITEM;
00562
00563
00564 GRE_LEGEND_POLY (
00565 GRE_LAYER *layer,
00566 ELEMTYPE ElemType
00567 );
00568
00569 #if defined(X_NATIVE) || defined(WIN32_MFC)
00570
00571 virtual ERRVALUE AddElemPrompted (
00572 MDLGPARENT dlgparent,
00573 const RVC::ELEMENT& element
00574 );
00575 #endif
00576
00577
00578 void AddItem (
00579 const POLYSTYLE& style,
00580 const MISTRING& label,
00581 const MISTRING& intlabel
00582 );
00583
00584
00585 void AddItem (
00586 const RVC::ELEMENT& element,
00587 const MISTRING& label,
00588 const MISTRING& intlabel
00589 );
00590
00591 ERRVALUE Setup (
00592 const POLYPARMS& parm,
00593 const RVC::OBJITEM& GeoObjItem,
00594 const RVC::OBJITEM& StyleObjItem
00595 );
00596
00597 private:
00598 #ifndef GENERATING_DOXYGEN_OUTPUT
00599 GRE_LEGEND_POLY (const GRE_LEGEND_POLY&);
00600 GRE_LEGEND_POLY& operator= (const GRE_LEGEND_POLY&);
00601 #endif // GENERATING_DOXYGEN_OUTPUT
00602 };
00603
00604
00605 class GRE_LEGEND_POLY::ITEM : public GRE_LEGEND::ITEMBASE {
00606 public:
00607
00608
00609 ITEM (
00610 const POLYSTYLE& style,
00611 const MISTRING& label,
00612 const MISTRING& intlabel
00613 );
00614
00615
00616 ITEM (
00617 const RVC::ELEMENT& element,
00618 const MISTRING& label,
00619 const MISTRING& intlabel
00620 );
00621
00622
00623 virtual ~ITEM (
00624 );
00625
00626
00627 virtual void Draw (
00628 const DRAWCONTEXT& dc,
00629 const LRECT2D& samplerect
00630 ) const;
00631
00632 #ifdef WIN32_MFC
00633
00634 virtual void DrawTreeView (
00635 void *hdc,
00636 const GRE_ELEMSAMPLE_DC& dc,
00637 const CRect& rect,
00638 bool HasFocus
00639 );
00640 #endif
00641
00642
00643 const POLYSTYLE& GetStyle (
00644 ) const { return (m_style); }
00645
00646
00647 bool HasSameStyle (
00648 const POLYSTYLE& style
00649 ) const;
00650
00651
00652 virtual bool HasTransparency (
00653 ) const;
00654
00655 private:
00656 #ifndef GENERATING_DOXYGEN_OUTPUT
00657 POLYSTYLE m_style;
00658 MISTRING m_intlabel;
00659
00660
00661 void DrawInteriorLabel (
00662 const DRAWCONTEXT& cd,
00663 const LRECT2D& samplerect
00664 ) const;
00665
00666 ITEM (const ITEM&);
00667 ITEM& operator= (const ITEM&);
00668 #endif
00669 };
00670
00671
00672
00673
00674 class GRE_LEGEND_COLORSAMPLE : public GRE_LEGEND {
00675 public:
00676
00677 class ITEM;
00678
00679
00680 GRE_LEGEND_COLORSAMPLE (
00681 GRE_LAYER *layer
00682 );
00683
00684
00685 void AddItem (
00686 const COLOR& color,
00687 const MISTRING& label
00688 );
00689
00690 private:
00691 #ifndef GENERATING_DOXYGEN_OUTPUT
00692 GRE_LEGEND_COLORSAMPLE (const GRE_LEGEND_COLORSAMPLE&);
00693 GRE_LEGEND_COLORSAMPLE& operator= (const GRE_LEGEND_COLORSAMPLE&);
00694 #endif // GENERATING_DOXYGEN_OUTPUT
00695 };
00696
00697 class GRE_LEGEND_COLORSAMPLE::ITEM : public GRE_LEGEND::ITEMBASE {
00698 public:
00699
00700
00701 ITEM (
00702 const COLOR& color,
00703 const MISTRING& label
00704 );
00705
00706
00707 virtual ~ITEM (
00708 );
00709
00710
00711 virtual void Draw (
00712 const DRAWCONTEXT& dc,
00713 const LRECT2D& samplerect
00714 ) const;
00715
00716 #ifdef WIN32_MFC
00717
00718 virtual void DrawTreeView (
00719 void *hdc,
00720 const GRE_ELEMSAMPLE_DC& dc,
00721 const CRect& rect,
00722 bool HasFocus
00723 );
00724 #endif
00725
00726
00727 const COLOR& GetColor (
00728 ) const { return (m_color); }
00729
00730
00731 bool HasSameStyle (
00732 const COLOR& color
00733 ) const;
00734
00735 private:
00736 #ifndef GENERATING_DOXYGEN_OUTPUT
00737 COLOR m_color;
00738 ITEM (const ITEM&);
00739 ITEM& operator= (const ITEM&);
00740 #endif // GENERATING_DOXYGEN_OUTPUT
00741 };
00742
00743
00744
00745
00746 class GRE_LEGEND_COLORSCALE : public GRE_LEGEND {
00747 public:
00748
00749 class ITEM;
00750
00751
00752 GRE_LEGEND_COLORSCALE (
00753 GRE_LAYER *layer
00754 );
00755
00756
00757 virtual void GetItemSizePixels (
00758 LPOINT2D& size
00759 ) const;
00760
00761
00762
00763 void SetValues (
00764 const SIMPLE_ARRAY<COLOR>& palette,
00765 const CBPARMS& ColorBalance,
00766 double MinValue,
00767 double MaxValue,
00768 bool VerticalMinAtTop
00769 );
00770
00771 private:
00772 #ifndef GENERATING_DOXYGEN_OUTPUT
00773 GRE_LEGEND_COLORSCALE (const GRE_LEGEND_COLORSCALE&);
00774 GRE_LEGEND_COLORSCALE& operator= (const GRE_LEGEND_COLORSCALE&);
00775 #endif // GENERATING_DOXYGEN_OUTPUT
00776 };
00777
00778 class GRE_LEGEND_COLORSCALE::ITEM : public GRE_LEGEND::ITEMBASE {
00779 public:
00780
00781
00782 ITEM (
00783 GRE_LEGEND_COLORSCALE& legend,
00784 const SIMPLE_ARRAY<COLOR>& palette,
00785 const CBPARMS& ColorBalance,
00786 double MinValue,
00787 double MaxValue,
00788 bool VerticalMinAtTop
00789 );
00790
00791
00792 virtual ~ITEM (
00793 );
00794
00795
00796 virtual void Draw (
00797 const DRAWCONTEXT& dc,
00798 const LRECT2D& samplerect
00799 ) const;
00800
00801 #ifdef WIN32_MFC
00802
00803 virtual void DrawTreeView (
00804 void *hdc,
00805 const GRE_ELEMSAMPLE_DC& dc,
00806 const CRect& rect,
00807 bool HasFocus
00808 );
00809 #endif
00810
00811
00812
00813 INT32 ValueToPosition (
00814 const GRE_LAYER_RASTER *layer,
00815 double value,
00816 INT32 size
00817 ) const;
00818
00819 private:
00820 #ifndef GENERATING_DOXYGEN_OUTPUT
00821 GRE_LEGEND_COLORSCALE& m_legend;
00822 SIMPLE_ARRAY<COLOR> m_palette;
00823 double m_MinValue;
00824 double m_MaxValue;
00825 bool m_MinAtTop;
00826
00827 ITEM (const ITEM&);
00828 ITEM& operator= (const ITEM&);
00829
00830 friend class GRE_LEGEND_COLORSCALE;
00831 #endif // GENERATING_DOXYGEN_OUTPUT
00832 };
00833
00834
00835
00836 #endif // INC_GRE_LEGEND_H