Introduction to AO's Display object II
Refreshing relatively failed
In order to cause a re-painting, this invalid program must be called. Most clients never use iscreendisplay: invalidate. This is because if a view is
This view should be refreshed when your program is called. This view shows the buffer and knows the best way to disable the execution. You only need to determine the partialrefresh call. 1. Stop
Invalid. To allow the view (MAP and pagelayout) to fully manage the display buffer, all invalid display buffers must pass the view. Call iactiveview: refresh always
Painting refers to an object. This is very inefficient. This method calls partialrefresh whenever possible. It allows you to specify what part of the view is re-painted and allows view and display buffer 1.
This method of painting is quick and efficient.
Draw phase |
Map |
Typographical |
Esriviewbackground |
No |
Page/SNAP Grid |
Esriviewgeography |
Layers |
No |
Esriviewgeoselection |
Feature Selection |
No |
Esriviewgraphics |
Labels/graphics |
Graphics |
Esriviewgraphicselection |
Graphic Selection |
Element Selection |
Esriviewforeground |
No |
Snap guides |
The following table shows some examples of calling Space refresh;
Operation |
Method call |
Refresh Layer |
Pmap. partialrefresh (esriviewgeography, player, 0) |
Refresh all layers |
Pmap. partialrefresh (esriviewgeography, 0, 0) |
Refresh Selection |
Pmap. partialrefresh (esriviewgeoselection, 0, 0) |
Refresh labels |
Pmap. partialrefresh (esriviewgraphics, 0, 0) |
Refresh Element |
Playout. partialrefresh (esriviewgraphics, pelement, 0) |
Refresh all elements |
Playout. partialrefresh (esriviewgraphics, 0, 0) |
Refresh Selection |
Playout. partialrefresh (esriviewgraphicselection, 0, 0) |
Note: any invalidation will invalidate the record buffer. To impose redraw on the Record Buffer, use the following method: pscreendisplay. invalidate (0, variant_false, esrinoscreencache );
Show events
This section describes the call events when a map is painted. The following provides a better insight into painting events, painting sequence, and display buffers.
Draw order
In order to better understand the map creation events, the following section describes the order in which each view object is painted.
Map (data view): The following shows the order from high to low. Each line is drawn above the following one:
Object |
Phase |
Buffer |
Graphic Selection |
Esriviewforeground |
None |
Clip border |
Esriviewforeground |
None |
Feature Selection |
Esriviewgeoselection |
Selection |
Auto labels |
Esriviewgraphics |
Annotation |
Graphics |
Esriviewgraphics |
Annotation |
Layer Annotation |
Esriviewgraphics |
Annotation |
Layers |
Esriviewgeography |
Layer (s) |
Background |
Esriviewbackground |
Bottom Layer |
Pagelayout:
Object |
Phase |
Buffer |
Snap guides |
Esriviewforeground |
None |
Selection |
Esriviewgraphicselection |
Selection |
Elements |
Esriviewgraphics |
Element |
Snap Grid |
Esriviewbackground |
Element |
Print margins |
Esriviewbackground |
Element |
Display Design Mode
To help you understand how to work with various display objects to solve general development needs, some application plots and details are given during their execution. Use these modes as the reference for displaying objects working together.
Application Window
One of the most common tasks is to draw a map in the client area of the application window that supports rolling and backup storage. This display object may be used in the following scenarios.
Initialization
When a window is created, create a screen
Start with display. You need to create one or more symbols to draw the shape. Send the application handle to pscreendisplay. hwnd. From it
Screen of idisplaytransformation Interface
Display to obtain and use ptransformation. bounds and pdisplaytransform. visiblebounds to set the full graph and
Scope. The visible range determines the current space level. Screen Display is concerned with updating the conversion display of deviceframe. Screen
Display manages window messages and general event handles like window size and scrolling.
Private m_pscreendisplay as iscreendisplay
Private m_pfillsymbol as isimplefillsymbol
Private sub form_load ()
Set m_pscreendisplay = new screendisplay
M_pscreendisplay.hwnd = picture1.hwnd
Set m_pfillsymbol = new simplefillsymbol
Dim penv as ienvelope
Set penv = new envelope
Penv. putcoords 0, 0, 50, 50
M_pscreendisplay.displaytransformation.bounds = penv
M_pscreendisplay.displaytransformation.visiblebounds = penv
End sub
Painting
The Display object defines a basic idraw interface, which is easy to draw on any display. As long as you use idraw or idisplay to execute your drawing code, you don't have to worry about drawing
Which of the following devices. A painting process starts with startdrawing and completes with finishdrawing. For example, create a program to create a polygon in the center of the screen and draw
It. This shape uses the default symbol.
Private function getpolygon () as ipolympus gon
Set getpolygon = new Polygon
Dim ppointcollection as ipointcollection
Set ppointcollection = getpolygon
Dim Ppoint as ipoint
Set Ppoint = new point
Ppoint. putcoords 20, 20
Ppointcollection. addpoint Ppoint
Ppoint. putcoords 30, 20
Ppointcollection. addpoint Ppoint
Ppoint. putcoords 30, 30
Ppointcollection. addpoint Ppoint
Ppoint. putcoords 20, 30
Ppointcollection. addpoint Ppoint
Getpolygon. Close
End Function
Private sub mydraw (pdisplay as idisplay, HDC as esrisystem. ole_handle)
'Draw from scratch
Dim pdraw as idraw
Set pdraw = pdisplay
Pdraw. startdrawing HDC, esrinoscreencache
Dim ppoly as ipolympus gon
Set ppoly = getpolygon ()
Pdraw. setsymbol m_pfillsymbol
Pdraw. Draw ppoly
Pdraw. finishdrawing
End sub
This program can draw a polygon in any device. In any case, we need to draw the window in the first place. To process this
Screen
Write some code to the mydraw program in the paint method of the display indicator and picturebox handle. Note that this program accepts the display
Indicator and window device.
Private sub picture1_paint ()
Mydraw m_pscreendisplay, picture1.hdc
End sub
Add display buffer
Some painting may take some time to complete. A simple method to improve
The performance is to run the display buffer. This involves Screen
The display capability is used to record your painting process to a bitmap. Then, whenever the painting method is called, The bitmap is used to refresh the image window. Until your data changes and you call
Iscreendisplay: invalidate to specify which buffer zone is invalid. This buffer zone will be used. There are two types of Buffers: one is the record buffer and the other is the user union.
Buffer zone. Use the record in the paint method of the application to execute the display buffer.
Private sub picture1_paint ()
If (m_pscreendisplay.iscachedirty (esriscreenrecording) then
M_pscreendisplay.startrecording
Mydraw m_pscreendisplay, picture1.hdc
M_pscreendisplay.stoprecording
Else
Dim rect as tagrect
M_pscreendisplay.drawcache picture1.hdc, esriscreenrecording, rect, rect
End if
End sub
When you execute this code, you will see nothing on the screen. This is because the screenrecording buffer is not set. To ensure that the mydraw function is called, when the painting message is received first, you must make the buffer invalid. Add the following row to the end of the form_load method.
M_pscreendisplay.invalidate nothing, true, esriscreenrecording
Some applications, such as ArcMAP, may need multiple display buffers. To use multiple buffers, follow these steps:
1. Use iscreendisplay: addcache to add a new buffer. The ID of the buffer to save when the returned result is returned.
2. To draw your buffer, specify the buffer ID to start with startdrawing.
3. to invalidate the buffer, the ID of the specified buffer is invalid, invalidate.
4. To draw from the buffer, specify the buffer ID and drawcache.
To change the application example to support its own buffer, make the following changes:
1) Add new variables to keep the new buffer.
Private m_lcacheid as long
2) create a buffer in the form_load Method
M_lcacheid = m_pscreendisplay.addcache
3) use the m_icacheid variable and remove the start and stop records from the paint method to change the call as appropriate.
Movement, size change, and Rotation
A powerful feature of displaying objects is to zoom in and out on your map. It is easy to execute with a zoom-in, zoom-out, or translation tool. Scroll is automatically processed. Narrow down your map and set your visible range. For example, add a button to the table and put the following code. This will change the screen by a fixed number, in the click event button.
Private sub commandementclick ()
Dim penv as ienvelope
Set penv = m_pscreendisplay.displaytransformation.visiblebounds
Penv. Expand 0.75, 0.75, true
M_pscreendisplay.displaytransformation.visiblebounds = penv
M_pscreendisplay.invalidate nothing, true, esriallscreencaches
End sub
Screen
Display executes the trackpan method. This call is mainly to press the mouse to let the user translate the view. You can set displaytransformation's
The rotation attribute value is used to rotate objects on the screen. Rotation indicates degree. Screen
Display executes the trackrotate method. This call allows users to rotate views by pressing the mouse.
Print
Printing is very similar to screen painting. When drawing to a printer, you don't have to worry about the buffer or roll
Dynamic, simple display is used. Create a simple Display object and copy the screen
Display changes to initialize its changes. Set the value of the pixel edge of the print page of the device frame that changes the printer. Finally, use simple
Display and printer handles are drawn from the sketch.
Output Metafile
This gdidisplay object is used to represent a dollar
File. There is a slight difference between creating a Metafile and printing. If you specify the lpbounds variable to 0 to createenhmetafile, this mydraw program can be used. Only
Use hprinterdc to replace hmetafiledc. If you want to specify the createenhmetaffile range, Set
The pixel version of The deviceframe of displaytransformation.
Print Structure
Some projects may need to directly output some lower-level rectangles to the output device. It is easy to process these by setting the device frame pixel range of displaytransformation to be less than the full device range.
Filter
Non
Often advanced rendering effects, such as color transparency, can be completed with excessive display considerations. Work with the display buffer to allow your raster version (rasterized
Version. When an excessively specified display view (idisplay: putrefy_displayfilter) is used, this display creates
The record buffer is used to provide an internal overhead buffer with grid information. The output is sent to the buffer (putref_displayfilter (0) until it is cleared )). At which point
Call idisplayfilter: Apply. apply to receive the current background Bitmap (Record Buffer), draw the buffer (including all the paintings that have been specified for consideration) and
Handle. Transparency over the execution of these bitmaps (alphblending) and get the color transparency to draw them to the target handle. New considerations can be created to execute other effects.
Example
Painting point
[C #]
Public void onmousedown (INT button, int shift, int X, int y)
{
Imxdocument mxdoc = m_app.document as imxdocument;
Iactiveview activeview = mxdoc. focusmap as iactiveview;
Iscreendisplay screendisplay = activeview. screendisplay;
Screendisplay. startdrawing (screendisplay. HDC, (short) esriscreencache. esrinoscreencache );
Screendisplay. setsymbol (New simplemarkersymbolclass ());
Screendisplay. drawpoint (mxdoc. currentlocation );
Screendisplay. finishdrawing ();
}
Draw line
Public void onmousedown (INT button, int shift, int X, int y)
{
Imxdocument mxdoc = m_app.document as imxdocument;
Iactiveview activeview = mxdoc. focusmap as iactiveview;
Iscreendisplay screendisplay = activeview. screendisplay;
Isimplelinesymbol linesymbol = new simplelinesymbolclass ();
Irgbcolor rgbcolor = new rgbcolorclass ();
Rgbcolor. red= 255;
Linesymbol. Color = rgbcolor;
Irubberband rubberline = new rubberlineclass ();
Ipolympus line newpolyline = (ipolympus line) rubberline. tracknew (screendisplay, (isymbol) linesymbol );
Screendisplay. startdrawing (screendisplay. HDC, (short) esriscreencache. esrinoscreencache );
Screendisplay. setsymbol (isymbol) linesymbol );
Screendisplay. drawpolyline (newpolyline );
Screendisplay. finishdrawing ();
}
Image
Public void onmousedown (INT button, int shift, int X, int y)
{
Imxdocument mxdoc = m_app.document as imxdocument;
Iactiveview activeview = mxdoc. focusmap as iactiveview;
Iscreendisplay screendisplay = activeview. screendisplay;
Isimplefillsymbol fillsymbol = new simplefillsymbolclass ();
Irgbcolor rgbcolor = new rgbcolorclass ();
Rgbcolor. red= 255;
Fillsymbol. Color = rgbcolor;
Irubberband rubberpolygon = new rubberpolygonclass ();
Ipolympus Gon newpolygon = (ipolympus gon) rubberpolygon. tracknew (screendisplay, (isymbol) fillsymbol );
Screendisplay. startdrawing (screendisplay. HDC, (short) esriscreencache. esrinoscreencache );
Screendisplay. setsymbol (isymbol) fillsymbol );
Screendisplay. drawpolygon (newpolygon );
Screendisplay. finishdrawing ();
}
Draw a rectangle
Public void onmousedown (INT button, int shift, int X, int y)
{
Imxdocument mxdoc = m_app.document as imxdocument;
Iactiveview activeview = mxdoc. focusmap as iactiveview;
Iscreendisplay screendisplay = activeview. screendisplay;
Isimplefillsymbol fillsymbol = new simplefillsymbolclass ();
Irgbcolor rgbcolor = new rgbcolorclass ();
Rgbcolor. red= 255;
Fillsymbol. Color = rgbcolor;
Irubberband rubberenv = new rubberenvelopeclass ();
Ienvelope newenvelope = (ienvelope) rubberenv. tracknew (screendisplay, (isymbol) fillsymbol );
Screendisplay. startdrawing (screendisplay. HDC, (short) esriscreencache. esrinoscreencache );
Screendisplay. setsymbol (isymbol) fillsymbol );
Screendisplay. drawrectangle (newenvelope );
Screendisplay. finishdrawing ();
}