I. Overview
Interactive Drawing, I understand, is to draw a graph with the mouse.
Interactive plotting is often used in GIS software development and design. For example, ArcGIS and other software have very complex human-computer interaction functions. Interactive plotting occupies an important position in GIS.
2. object-oriented modeling of Elements
In interactive drawing, you can view the elements of the drawing as basic elements, such as text, points, line segments, line breaks, polygon, elliptical, circle, and arc segments. In order to express these elements, we can use the object-oriented idea for modeling. First, an abstract base class can be used to represent all primitive classes. The abstract base class has the draw method, and the specific primitive class above inherits from this abstract base class, the draw method must be implemented to complete the painting. The detailed class diagram is as follows:
3. Interactive Drawing Tool construction
If the system development adopts the single-document view structure of MFC, maps are usually displayed in the view, and map operations are converted to operations in the view. If you write a message response function for each map operation in the View class, the code page of the View class will continue to expand as the application expands, resulting in code bloated, poor management, increasing the burden on developers and maintenance personnel. In this case, map operations can be abstracted as a tool. Here, I call it maptool, which can capture the message response of the View class, to implement a specific operation, you only need to inherit this class and implement the Response Message response function to implement map operations, in this way, the coupling between the interface and logic will be greatly reduced, and the maintenance cost is also reduced. For example, in map browsing, we often use functions such as box zoom-in and box translation. In the plotting function, there are drawing rectangular, line, polygon, and circle images. These operations are encapsulated in a separate class to reduce coupling between modules. This part of the design can be implemented in the bridge mode or command mode.
4. Examples of interactive plotting
I talked about the construction of the drawing tool and the modeling of the elements. Why haven't I talked about how to draw it? Don't worry. Let's start talking about it below.
1. rectangle and circle
Why are these two images put in one lecture mainly because the two drawing methods are the same. First, press the left button, and then move the mouse to generate dynamic images, the last step is to draw the image with the mouse popping up. For more information about dynamic rectangular drawing, see my other blog http://blog.csdn.net/zhouxuguang236/article/details/7686163.
Is a specific example of drawing.
The following figure shows the enlarged image.
The above two images are drawn on the remote sensing image, and the image is displayed on the screen after the frame is enlarged, at this time, because I add the rectangle to the temporary Drawing Layer after drawing, the map still stays in the view as it is operated. Of course, you can also select elements and perform other operations.
2. Polygon
The dynamic drawing of polygon is to draw a dynamic polygon with the left mouse click to determine the first point, and then draw a dynamic polygon while moving the mouse. When you press the left mouse button again, the second point is determined, and so on. Finally, the polygon is drawn.
V. Postscript
I have written so much today, and there are still a lot of interactive plotting content. This article is just a reference. You are welcome to discuss all aspects of GIS software design.