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 #ifndef INC_GRE_LRRASTER_H
00055 #define INC_GRE_LRRASTER_H
00056
00057 #ifndef INC_GRE_LAYER_H
00058 #include <gre/layer.h>
00059 #endif
00060
00061 #ifndef INC_GRE_LEGEND_H
00062 #include <gre/legend.h>
00063 #endif
00064
00065 #ifndef INC_MI32_RELSHADE_H
00066 #include <mi32/relshade.h>
00067 #endif
00068
00069 #ifndef INC_GRE_3DFILTER_H
00070 #include <gre/3dfilter.h>
00071 #endif
00072
00073 #ifndef INC_GRE_3DBOUND_H
00074 #include <gre/3dbound.h>
00075 #endif
00076
00077 #ifndef GENERATING_DOXYGEN_OUTPUT
00078 namespace MGD {
00079 class DEVICE_MEM24;
00080 }
00081 namespace RVC {
00082 class NULLMASK;
00083 }
00084 #endif
00085
00086
00087
00088
00089 #define RASTGRADMIN -127
00090 #define RASTGRADMAX 127
00091 #define RASTGRADOFFSET 128
00092 #define RASTGRADRANGE 256
00093
00094
00095 class GRE_LAYER_RASTER : public GRE_LAYER {
00096 public:
00097
00098 enum SUBTYPE {
00099 SUBTYPE_Single = 0,
00100 SUBTYPE_Hyperspectral = 1,
00101 SUBTYPE_MultiCI = 2,
00102 SUBTYPE_MultiRGB = 3,
00103 SUBTYPE_MultiHIS = 4,
00104 SUBTYPE_MultiHBS = 5,
00105 SUBTYPE_MultiRGBI = 6,
00106 SUBTYPE_MultiCMY = 7,
00107 SUBTYPE_MultiCMYK = 8,
00108 SUBTYPE_External = 9
00109 };
00110
00111
00112 class DISPPARM : public GRE_LAYER::DISPPARM {
00113 public:
00114
00115 class DLG;
00116
00117
00118 struct IOPARM {
00119 public:
00120 MIUNICODE filename[FILENAME_MAX];
00121 RVC::OBJECTNAME m_GeorefName;
00122 int fhandle;
00123 int ohandle;
00124 RVCRASTINFO objinfo;
00125 CONTPARM contparm;
00126 RASTSHADEPARM shadeparm;
00127 DATATIPPARMS DataTip;
00128 double minvalue;
00129 double maxvalue;
00130 bool DoContrast;
00131 bool ReadWrite;
00132 bool HasNull;
00133 bool DiagonalBuffer;
00134 bool IsSubRast;
00135 UINT8 IsConstant;
00136 UINT8 DoShading;
00137 INT32 Band;
00138 int (*OpenRast) (IOPARM *);
00139 int (*ReadRast) (IOPARM*, INT32 lin, INT32 col, INT32 numcols, void *rastbuf, UINT8* nullbuf);
00140 int (*CloseRast) (IOPARM *);
00141 int (*SetCacheRect) (IOPARM*, const LRECT2D&);
00142 RVC::NULLMASK *m_pObjNull;
00143 DISPPARM *dp;
00144 void *privptr;
00145 bool m_HasSaveInfo;
00146 mutable FILEPATH m_savefilepath;
00147 mutable RVCINODENUM m_saveobjinode;
00148 mutable RVCINODENUM m_savecontinode;
00149
00150 IOPARM ();
00151 IOPARM (
00152 const IOPARM& rhs
00153 ) { Copy(rhs); }
00154 ~IOPARM (
00155 ) { Free(); }
00156
00157 static ERRVALUE SerializerCB (SERIALIZER&, const SERIALIZER::ITEMDEF*, void*, SERIALIZER::ITEMDEF::ACTION);
00158
00159 IOPARM& operator= (
00160 const IOPARM& rhs
00161 ) { if (this != &rhs) { Free(); Copy(rhs); } return (*this); }
00162
00163 void Close ();
00164 private:
00165 #ifndef GENERATING_DOXYGEN_OUTPUT
00166 void Copy (const IOPARM&);
00167 void Free ();
00168 void OnSerialRead();
00169 void UpdateSaveInfo() const;
00170 friend class DISPPARM;
00171 #endif
00172 };
00173
00174
00175 struct SHADEBUF {
00176 public:
00177
00178 UINT8 gradgray[RASTGRADRANGE*RASTGRADRANGE];
00179 UINT16 *linebuf;
00180 INT32 linebufcols;
00181 double *idata0;
00182 double *idata1;
00183 double nullvalD;
00184
00185 SHADEBUF (
00186 ) {
00187 memset(this,0,sizeof(*this));
00188 }
00189 ~SHADEBUF (
00190 );
00191
00192 private:
00193 #ifndef GENERATING_DOXYGEN_OUTPUT
00194 SHADEBUF (const SHADEBUF&);
00195 SHADEBUF& operator= (const SHADEBUF&);
00196 #endif // GENERATING_DOXYGEN_OUTPUT
00197 };
00198
00199
00200 class COLORSCALELABEL {
00201 public:
00202 double CellValue;
00203 MISTRING Label;
00204
00205
00206 COLORSCALELABEL (
00207 ) :
00208 CellValue(0.0)
00209 { }
00210
00211
00212 COLORSCALELABEL (
00213 const COLORSCALELABEL& rhs
00214 ) :
00215 CellValue(rhs.CellValue),
00216 Label(rhs.Label)
00217 { }
00218
00219
00220 ~COLORSCALELABEL() {
00221 }
00222
00223
00224 COLORSCALELABEL& operator= (
00225 const COLORSCALELABEL& rhs
00226 ) { if (this != &rhs) { CellValue = rhs.CellValue; Label = rhs.Label; } return (*this); }
00227 };
00228
00229 IOPARM ioparm[4];
00230 IOPARM maskioparm;
00231 UINT8 dispmode;
00232 UINT8 ColorBlendMode;
00233 UINT8 ColorBlendFactor;
00234 UINT8 Transparency;
00235 UINT8 UseMask;
00236 UINT8 PreferredZoom1X;
00237 bool LoadColMap;
00238 bool UseColMap;
00239 SIMPLE_ARRAY<COLOR> colmap;
00240 RVC::OBJECTNAME m_ColorPaletteName;
00241 INT32 OutTileCols;
00242 INT32 OutTileLins;
00243 INT32 NumBands;
00244 CBPARMS ColorBalance;
00245 UINT8 LegendType;
00246 UINT8 LegendSampleArea;
00247 UINT8 LegendScaleMinAtTop;
00248 UINT16 LegendScaleRangeCount;
00249 LEGENDPARMS ColorSampleLegend;
00250 double xscale, yscale;
00251 SHADEBUF *shadebuf;
00252 MILIST<COLORSCALELABEL> ScaleLabels;
00253 double ScaleMin;
00254 double ScaleMax;
00255 double ScaleScale;
00256 double ScaleOffset;
00257 double ScaleInterval;
00258 bool ScaleMinOnTop;
00259 bool ScaleIsAuto;
00260 UINT8 ScalePlaces;
00261 GRE::TEXTUREFILTER::MODE TextureFilterMode;
00262 UINT8 AnisotropicLimit;
00263 UINT8 MipMapSharpness;
00264 GRE::BOUNDPARM m_Pedestal;
00265 GRE::BOUNDPARM m_Fence;
00266
00267 DISPPARM ();
00268 DISPPARM (
00269 const DISPPARM& rhs
00270 ): GRE_LAYER::DISPPARM(rhs) { Copy(rhs); }
00271 virtual ~DISPPARM (
00272 ) { Free(); }
00273
00274 DISPPARM& operator= (
00275 const DISPPARM& rhs
00276 ) { if (this != &rhs) { Free(); Copy(rhs); } return (*this); }
00277
00278 #ifndef GENERATING_DOXYGEN_OUTPUT
00279 static int SerializerCB_ColorPalette (SERIALIZER&, const SERIALIZER::ITEMDEF*, void*, SERIALIZER::ITEMDEF::ACTION);
00280 static int SerializerCB_ColorScaleLabels (SERIALIZER&, const SERIALIZER::ITEMDEF*, void*, SERIALIZER::ITEMDEF::ACTION);
00281 #endif // GENERATING_DOXYGEN_OUTPUT
00282
00283 protected:
00284 virtual const SERIALIZER::ITEMDEF* SerialGetItemDef (SERIALIZER& serializer) const;
00285 virtual ERRVALUE SerialRead (SERIALIZER& serializer);
00286 virtual ERRVALUE SerialWrite (SERIALIZER& serializer, const char *tagname = 0) const;
00287
00288 private:
00289 #ifndef GENERATING_DOXYGEN_OUTPUT
00290 void Close ();
00291 void Copy (const DISPPARM&);
00292 void Free ();
00293 void UpdateSaveInfo () const;
00294
00295 virtual ERRVALUE v_SetObjItem (const RVC::OBJITEM& objitem, bool replace);
00296 virtual ERRVALUE v_Validate ();
00297
00298 friend class GRE_LAYER_RASTER;
00299 #endif
00300 };
00301
00302
00303
00304 class LEGEND_IMAGESAMPLE : public GRE_LEGEND {
00305 public:
00306
00307
00308 class ITEM : public GRE_LEGEND::ITEMBASE {
00309 public:
00310
00311 ITEM (
00312 MGD::DEVICE_MEM24 *& SampleMem,
00313 const MISTRING& label
00314 );
00315
00316
00317 virtual ~ITEM (
00318 );
00319
00320
00321 virtual void Draw (
00322 const DRAWCONTEXT& dc,
00323 const LRECT2D& samplerect
00324 ) const;
00325
00326 #ifdef WIN32_MFC
00327
00328 virtual void DrawTreeView (
00329 void *hdc,
00330 const GRE_ELEMSAMPLE_DC& dc,
00331 const CRect& rect,
00332 bool HasFocus
00333 );
00334 #endif
00335
00336 private:
00337 #ifndef GENERATING_DOXYGEN_OUTPUT
00338 MGD::DEVICE_MEM24 *m_pSampleMem;
00339
00340 ITEM (const ITEM&);
00341 ITEM& operator= (const ITEM&);
00342 #endif // GENERATING_DOXYGEN_OUTPUT
00343 };
00344
00345
00346 explicit LEGEND_IMAGESAMPLE (
00347 GRE_LAYER_RASTER *layer
00348 );
00349
00350
00351
00352 int AddItem (
00353 const LPOINT2D& center,
00354 const MISTRING& label
00355 );
00356
00357
00358
00359 virtual void GetItemSizePixels (
00360 LPOINT2D& size
00361 ) const;
00362
00363
00364 void SetItemSize (
00365 INT32 xsize,
00366 INT32 ysize
00367 ) {
00368 if (m_ItemSize.x != xsize || m_ItemSize.y != ysize) {
00369 DeleteAllItems();
00370 m_ItemSize.x = xsize;
00371 m_ItemSize.y = ysize;
00372 }
00373 return;
00374 }
00375
00376 private:
00377 #ifndef GENERATING_DOXYGEN_OUTPUT
00378 LPOINT2D m_ItemSize;
00379
00380 LEGEND_IMAGESAMPLE (const LEGEND_IMAGESAMPLE&);
00381 LEGEND_IMAGESAMPLE& operator= (const LEGEND_IMAGESAMPLE&);
00382 #endif // GENERATING_DOXYGEN_OUTPUT
00383 };
00384
00385
00386 static void RegisterType (
00387 );
00388
00389
00390 static void SMLClassInstall (
00391 SMLCONTEXT *context
00392 );
00393
00394
00395 explicit GRE_LAYER_RASTER (
00396 GRE_GROUP *group,
00397 CREATEFLAGS createflags = CREATEFLAG_None,
00398 GRE::LISTPOS listpos = GRE::LISTPOS_Last,
00399 GRE_LAYER *reflayer = 0
00400 );
00401
00402 virtual ~GRE_LAYER_RASTER ();
00403
00404
00405
00406 virtual int OpenObject (
00407 UINT32 filemode = RVCFILE_ReadLock,
00408 MDLGPARENT dlgparent = 0
00409 );
00410
00411
00412 ERRVALUE AssignObjects (
00413 SUBTYPE subtype,
00414 const RVC::OBJITEMLIST& objitems
00415 );
00416
00417 bool CanDoShading (
00418 ) const;
00419
00420
00421
00422 const DISPPARM& GetDispParm (
00423 ) const {
00424 return (m_dispparm);
00425 }
00426
00427
00428 GRE_LEGEND_COLORSAMPLE& GetColorSampleLegend (
00429 ) {
00430 return (m_ColorSampleLegend);
00431 }
00432
00433 #if defined(X_NATIVE) || defined(WIN32_MFC)
00434
00435 int PromptObjects (
00436 SUBTYPE subtype,
00437 bool OpenCtrlPanel = false,
00438 MDLGPARENT dlgparent = 0
00439 );
00440 #endif
00441
00442
00443 int SetColorMap (
00444 const SIMPLE_ARRAY<COLOR>& colmap,
00445 const RVC::OBJECTNAME& ColorPaletteName
00446 );
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456 ERRVALUE SetDispParm (
00457 const DISPPARM& dispparm
00458 );
00459
00460
00461 ERRVALUE SetMask (
00462 const RVC::OBJITEM& objitem
00463 );
00464
00465 void SetObjRegion (
00466 const REGION2D& ObjRegion
00467 ) { m_ObjRegion = ObjRegion; }
00468
00469
00470 void SetShadeAngles (
00471 double AzimAngle,
00472 double ElevAngle
00473 );
00474
00475
00476 void SetVisibleExtents (
00477 const LRECT2D& rect
00478 );
00479
00480
00481 int UpdateContrastFromRegion (
00482 const REGION2D& region
00483 );
00484
00485 void ClearPedestal (
00486 ) {if (m_Texture != 0) m_Texture->ClearPedestal(); return; };
00487
00488 protected:
00489
00490 DISPPARM m_dispparm;
00491
00492 private:
00493 #ifndef GENERATING_DOXYGEN_OUTPUT
00494
00495 GRE::TEXTURE *m_Texture;
00496
00497 static void LegendMsgHandler (GRAPHICTREEITEM_MSG *msg);
00498 #ifdef X_NATIVE
00499 static void CB_ActionTool (Widget, void*, void*);
00500 static void MCB_AdjustShading (MxdAnyCallbackStruct*, GRE_LAYER_RASTER*);
00501 static void MCB_AutoColorMapApply (MxdAnyCallbackStruct*, GRE_LAYER_RASTER*);
00502 static void MCB_ColorBalance (MxdAnyCallbackStruct*, GRE_LAYER_RASTER*);
00503 static void MCB_EditColorMap (MxdAnyCallbackStruct*, GRE_LAYER_RASTER*);
00504 #endif
00505
00506 GRE_LEGEND_COLORSAMPLE m_ColorSampleLegend;
00507 GRE_LEGEND_COLORSCALE m_ColorScaleLegend;
00508 LEGEND_IMAGESAMPLE m_ImageSampleLegend;
00509 COMPINFO m_CompInfo[4];
00510 mutable RVC::OBJITEM m_TempObjItem[4];
00511
00512 ERRVALUE CreateRasterLink (MDLGPARENT dlgparent);
00513 ERRVALUE Draw2D (GRE_LAYERDC *layerdc);
00514 ERRVALUE Draw3D (GRE_LAYERDC *layerdc);
00515 void LegendReadSample (GRAPHICTREEITEM_MSG *msg);
00516 void OnActionTool (int);
00517 void SetupLegend ();
00518
00519 ERRVALUE SetupPyramid (
00520 const TRANS2D_MAPGEN& tmg,
00521 LRECT2D *DispUsedRect,
00522 INT32 *psampleret,
00523 int *needpyramid
00524 );
00525
00526 int SetupShading ();
00527
00528
00529 #ifdef WIN32_MFC
00530 virtual void v_AddTreeViewDetails (GRE_MFC_TREEVIEW& TreeView, HTREEITEM hParent, HTREEITEM hInsertAfter);
00531 virtual void v_AddTreeViewLegend (GRE_MFC_TREEVIEW& TreeView, HTREEITEM hParent, HTREEITEM hInsertAfter);
00532 #endif
00533 virtual ERRVALUE v_AssignObject (const RVC::OBJITEM& objitem, MDLGPARENT dlgparent);
00534 virtual bool v_CanShowDetails () const;
00535 virtual void v_CloseObject ();
00536 #if defined(X_NATIVE) || defined(WIN32_MFC)
00537 virtual int v_ControlPanel (MDLGPARENT dlgparent, UINT32 flags = 0);
00538 #endif
00539 virtual GRE_LAYER* v_Copy (GRE_GROUP *group) const;
00540 virtual void v_DataTipGetDefaultPrefix (int component, DATATIPPARMS& DataTipParms) const;
00541 virtual const DATATIPPARMS& v_DataTipGetParms (int component) const;
00542 virtual ERRVALUE v_DataTipSetParms (int component, const DATATIPPARMS& DataTipParms);
00543 virtual ERRVALUE v_Draw (GRE_LAYERDC& layerdc);
00544 virtual INT32 v_FindClosestElement (const DPOINT2D& point, double searchdist, double *distret, int component, const UINT8 *SearchSet, GRE_FIND_FLAGS findflags);
00545 virtual int v_GetComponent (ELEMTYPE ElemType) const;
00546 virtual MICON v_GetComponentIcon (int component) const;
00547 virtual COMPINFO* v_GetComponentInfo (int component);
00548 virtual MISTRING v_GetComponentName (int component) const;
00549 virtual UINT16 v_GetElemDrawSelectionMode (ELEMTYPE ElemType) const;
00550 virtual ELEMTYPE v_GetElemType (int component) const;
00551 virtual bool v_GetGeorefName (RVC::OBJECTNAME& name, int component = 0) const;
00552 virtual const GRE_LEGEND* v_GetLegend (ELEMTYPE ElemType);
00553 virtual INT32 v_GetNumElements (ELEMTYPE ElemType);
00554 virtual const RVC::OBJITEM& v_GetObjItem (int component) const;
00555 #ifdef X_NATIVE
00556 virtual MENUITEM* v_GetToolMenu () const;
00557 #endif
00558 #ifdef WIN32_MFC
00559 virtual bool v_HasTreeViewLegend () const;
00560 #endif
00561 virtual bool v_HasNullImageCells () const;
00562 #if defined(X_NATIVE) || defined(WIN32_MFC)
00563 virtual ERRVALUE v_PromptObject (bool OpenCtrlPanel, MDLGPARENT dlgparent);
00564 #endif
00565 virtual const char* v_SerialGetTagName () const;
00566 virtual void v_SetDftName (bool ReplaceExisting);
00567 virtual int v_UpdateExtents (bool forceupdate);
00568
00569 friend class LEGEND_IMAGESAMPLE;
00570
00571 GRE_LAYER_RASTER (const GRE_LAYER_RASTER&);
00572 GRE_LAYER_RASTER& operator= (const GRE_LAYER_RASTER&);
00573
00574 #endif
00575 };
00576
00577
00578 #define RASTERLEGENDTYPE_SampleArea 0
00579 #define RASTERLEGENDTYPE_ColorScaleContinuous 1
00580 #define RASTERLEGENDTYPE_ColorSample 2
00581 #define RASTERLEGENDTYPE_None 3
00582 #define RASTERLEGENDTYPE_ColorScaleRanges 4
00583
00584
00585
00586
00587 #endif