Presentation is loading. Please wait.

Presentation is loading. Please wait.

Pixel Editor PX 1.0 Ajay Prasad.

Similar presentations


Presentation on theme: "Pixel Editor PX 1.0 Ajay Prasad."— Presentation transcript:

1 Pixel Editor PX 1.0 Ajay Prasad

2 Agenda Utility Terminology Design Interface Future Reference PX 1.0

3 Terminology “The Component Object Model (COM) is a software architecture that allows applications to be built from binary software components. COM is the underlying architecture that forms the foundation for higher-level software services, like those provided by OLE (Object Linking and Embedding). OLE services span various aspects of commonly needed system functionality, including compound documents, custom controls, interapplication scripting, data transfer, and other software interactions. “ Client Process On the same machine Server Process Component COM Client PX 1.0

4 ArcObjects Terminology ArcObjects™ is the development platform for the ArcGIS™ family of applications such as ArcMap™, ArcCatalog™, and ArcScene™ ArcObjects is a framework that lets you create domain-specific components from other components. ArcObjects provides an infrastructure for application customization that lets you concentrate on serving the specific needs of your clients. ArcObjects is built using Microsoft’s Component Object Model (COM) technology. PX 1.0

5 Key ArcObjects Used….. ICommand ITool IMap IEnvelope IPoint
Terminology ESRI Object Library as project reference ICommand Provides access to members that define a COM command. To query the properties of a COM command or to create your own COM command. ITool Provides access to members that define a tool. To query the properties of a built-in tool or to create your own COM tool. IMap Provides access to members that control the map. To display data from various data sources. IEnvelope Provides access to methods and properties of envelopes. Envelope is defined by the XMin, XMax, YMin, and YMax of the object. IPoint Provides access to members that define two dimensional points.   Point represents a specific (X, Y) location in a the two-dimensional XY-Plane.  A Point may also have Z, M, and ID attributes associated with it.  PX 1.0

6 Key Sub Routines and Functions…
Design Function setDocMap(mApp As IApplication) As IRaster Sets document’s focus map and finds Raster layers present Sub Map2Dataset(ByVal pMapPoint As IPoint) Converts pMapPoint.X and pMapPoint.Y to Column number and Row number Public Sub showPixelMap(pRaster As IRaster, pPoint As IPoint) Reads the Pixel values from the Raster layer and displays in 3 X 3 Table. Private Sub cmdSave_Click() Write the new pixel values to the Raster Layer. Private Sub updateSymbology() Updates the Symbology to stretched category with new pixel values (Optional) PX 1.0

7 The Tool Interface Raster Layers in the map Shows “Edit history”
Zoom out to the Extent Get the Pixel values around specified Row and Column Zoom to the Column and Row Pixel Values Overwrite values with new one Reset with old values Change Symbology to Stretched Category PX 1.0

8 Significance Utility Attribute Table Unable to edit value of the pixel at a particular coordinate. PX 1.0 enables edit feature at desirable coordinates. PX 1.0

9 Rows and Columns of the Pixel Display Table can be modified
Version “ PX 1.1 ” Future Rows and Columns of the Pixel Display Table can be modified Test with different data types and grids To be compatible with MapWindow 3.0 More utilities which helps users to do the edits more efficiently Suggestions and Feedback from users PX 1.0

10 Acknowledgment and Reference
Dr David G Tarboton Professor, Civil and Environmental Engineering Utah State University Exploring ArcObjects Vol. I and II Geographic Data Management – Edited by Michael Zeiler GIS by ESRI TM PX 1.0

11 PX 1.0

12 PX 1.0

13 Object Linking and Embedding
Terminology An object system created by Microsoft. OLE lets the author invoke different editor components to create a compound document. Microsoft's comprehensive object strategy is built around the OLE object model and is designed to provide developers with a consistent and open standard for defining what an object is and how objects interact with one another. OLE technology is now an integral part of custom controls, creating a new open standard for component-based software development. PX 1.0

14 ICommand and ITool Terminology ICommand interface sets command properties such as caption, name, category, bitmap, status bar message, tool tip, help context id and help file, enabled state, and checked state. It also defines what action happens when the command is clicked. When you are creating a new COM tool, you need to implement both the ICommand interface and the ITool interface in your class code. With the ITool interface you can define what occurs on events such as mouse move, mouse button press/release, keyboard key press/release, double-click, and right click. PX 1.0

15 IEnvelope Terminology PX 1.0

16 IPoint Terminology PX 1.0

17 IMap Terminology The IMap interface is a starting point for many of the tasks one does with a Map. Use IMap to add, delete, and access map layers containing data from various sources including feature layers and graphics layers; associate map surround objects (legends, scale bars, etc) with the Map; access the various properties of a Map including the area of interest, the current map units, and the spatial reference; select features and access the Map's current selection. PX 1.0

18 setDocMap Design Function setDocMap(mApp As IApplication) As IRaster 'no input raster Set pMxDoc = mApp.Document Set pActiveView = pMxDoc.FocusMap Set pMap = pMxDoc.FocusMap Set pEnumLayer = pMap.Layers Set pLayer = pEnumLayer.Next If isloaded = False Then If TypeOf pLayer Is IRasterLayer Then Set pRLayer = pLayer pathName = pRLayer.FilePath Set setDocMap = pRLayer.Raster End If Else Dim i As Integer cboItem = IIf(frmPixelMap.cboRasterLayers.ItemData(frmPixelMap.cboRasterLayers.ListIndex) < 0, 1, frmPixelMap.cboRasterLayers.ItemData(frmPixelMap.cboRasterLayers.ListIndex)) pEnumLayer.Reset For i = 0 To cboItem If TypeOf pLayer Is IRasterLayer Then Set pLayer = pEnumLayer.Next Next popCombo End Function End Sub PX 1.0

19 Map2Dataset Design Sub Map2Dataset(ByVal pMapPoint As IPoint)
On Error GoTo myErr Dim pRasProp As IRasterProps Dim nx As Double, ny As Double Dim a1 As Double, b1 As Double, a2 As Double, b2 As Double If pMapPoint Is Nothing Then MsgBox "Map point object is null", vbCritical, "Raised Error" Exit Sub End If Set pRasProp = pRas g_Wid = pRasProp.Width g_Hgt = pRasProp.Height Dim pEnv As IEnvelope Set pEnv = pRasProp.Extent pEnv.QueryCoords g_ex1, g_ey1, g_ex2, g_ey2 nx = g_Wid ny = g_Hgt a1 = (nx) / (g_ex2 - g_ex1) ' # of pixels / map unit -- for x-axis b1 = -g_ex1 * a1 a2 = (ny) / (g_ey2 - g_ey1) ' # of pixels / map unit -- for y-axis b2 = -g_ey1 * a2 PX 1.0

20 ……………………. Design '/////For zoom in purpose ac1 = a1 ac2 = a2 bc1 = b1
Dim pDataPoint As IPoint Set pDataPoint = New Point Dim v As Long pDataPoint.X = Int(pMapPoint.X * a1 + b1) 'the number of rows to the point v = Int(pMapPoint.Y * a2 + b2) pDataPoint.Y = g_Hgt - v - 1 'number of columns to the point Set pMapPoint = pDataPoint frmPixelMap.Show frmPixelMap.ZOrder (0) frmPixelMap.showPixelMap pRas, pMapPoint isloaded = True Set pDataPoint = Nothing myErr: If Err.Number <> 0 Then MsgBox "Map2Dataset:" & Err.Description End Sub PX 1.0

21 showPixelMap Design Public Sub showPixelMap(pRaster As IRaster, pPoint As IPoint) ' Dim pRaster As IRaster Dim vArr As Variant On Error GoTo er Screen.MousePointer = vbHourglass ' get current band index Dim pRD As IRasterDataset Dim pBC As IRasterBandCollection Set pRD = OpenRasterDataset(pathName) Set pBC = pRD Set g_pEditBand = pBC.Item(0) Set g_pTrans = g_pEditBand g_Edits = 0 g_pTrans.UndoLevels = 5 Set pRasterProp = pRaster ' create pixelblock the size of the input raster Set pSize = New DblPnt pSize.SetCoords 3, 3 Set pPixelBlock = pRaster.CreatePixelBlock(pSize) Set pRawPixel = g_pEditBand ' get vb supported pixel type ' pRasterProp.PixelType = GetVBSupportedPixelType(pRasterProp.PixelType) ' get pixeldata xCell = pPoint.X yCell = pPoint.Y 'showing Rows and columns txtColumn = xCell txtRow = yCell Set pOrigin = New DblPnt pOrigin.SetCoords pPoint.X - 1, pPoint.Y - 1 pRawPixel.Read pOrigin, pPixelBlock vArr = pPixelBlock.SafeArray(0) PX 1.0

22 ………………….. Design ' show pixel data in the grid Dim inc As Integer
For irow = 0 To 2 ' set cell size For icol = 0 To 2 txtEdit.Item(inc) = IIf(vArr(icol, irow) >= 0, FormatNumber(vArr(icol, irow), 6), "Nodata") resetValues(inc) = txtEdit.Item(inc) inc = inc + 1 Next icol Next irow ' cleanup Set pRaster = Nothing Set pRasterProp = Nothing Set pSize = Nothing Set pOrigin = Nothing Screen.MousePointer = vbDefault Exit Sub er: If Err.Number <> 0 Then MsgBox "Failed to get pixel data: " & Err.Description For inc = 0 To 8 txtEdit.Item(inc) = "" Next End If End Sub PX 1.0

23 cmdSave_Click() Design Private Sub cmdSave_Click()
On Error GoTo catchError Dim pSafeArray As Variant, irow As Integer, icol As Integer Dim pBandCol As IRasterBandCollection Dim pBand As IRasterBand Dim X As Integer, Y As Integer, i As Integer For i = 0 To 8 If IsNumeric(txtEdit(i)) = False Then MsgBox "Invalid number.", vbExclamation + vbOKOnly Exit Sub End If Next i pSafeArray = pPixelBlock.SafeArray(0) ' set cell size X = xCell Y = yCell Dim inc As Integer inc = 0 For irow = 0 To 2 For icol = 0 To 2 pSafeArray(icol, irow) = FormatNumber(txtEdit.Item(inc), 6) inc = inc + 1 Next icol Next irow PX 1.0

24 ………………… Design 'create a dblpnt Dim pPnt As IPnt Set pPnt = New DblPnt
g_pTrans.Start pPnt.SetCoords xCell - 1, yCell - 1 pRawPixel.Write pPnt, pPixelBlock '///////////////////////////////////////////////////////// If chkUpdateSymbology.Value = 1 Then updateSymbology '/////////////////////////////////////////////////////// pActiveView.PartialRefresh esriViewGeography + esriViewGraphics, Nothing, Nothing If chkUpdateSymbology.Value = 1 Then pMxDoc.UpdateContents g_Edits = g_Edits + 1 g_pTrans.End Exit Sub catchError: helloError Err.Number, Err.Description End Sub PX 1.0

25 updateSymbology() Design Private Sub updateSymbology()
Dim pRenLayer As IRasterLayer Set pRenLayer = pMap.Layer(IIf(cboRasterLayers.ListIndex > -1, cboRasterLayers.ItemData(cboRasterLayers.ListIndex), 0)) Dim pRaster As IRaster Set pRaster = pRenLayer.Raster ' Create renderer and QI RasterRenderer Dim pStretchRen As IRasterStretchColorRampRenderer Set pStretchRen = New RasterStretchColorRampRenderer Dim pRasRen As IRasterRenderer Set pRasRen = pStretchRen ' Set raster for the renderer and update Set pRasRen.Raster = pRaster pRasRen.Update ' Define two colors Dim pFromColor As IColor Dim pToColor As IColor Set pFromColor = New RgbColor pFromColor.RGB = RGB(255, 0, 0) Set pToColor = New RgbColor pToColor.RGB = RGB(0, 255, 0) Create color ramp Dim pRamp As IAlgorithmicColorRamp Set pRamp = New AlgorithmicColorRamp pRamp.Size = 255 pRamp.FromColor = pFromColor pRamp.ToColor = pToColor pRamp.CreateRamp True PX 1.0

26 ……………………….. Design ' Plug this colorramp into renderer and select a band pStretchRen.BandIndex = 0 pStretchRen.ColorRamp = pRamp ' Update the renderer with new settings and plug into layer pRasRen.Update Set pRenLayer.Renderer = pStretchRen End Sub ' PX 1.0


Download ppt "Pixel Editor PX 1.0 Ajay Prasad."

Similar presentations


Ads by Google