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