Click here to Skip to main content
15,867,453 members
Articles / Desktop Programming / MFC
Article

A Simple Vector Editor

Rate me:
Please Sign up or sign in to vote.
4.85/5 (10 votes)
5 Jun 20022 min read 121.6K   1.4K   29   17
A simeple editor to make my polygon class a bit more usable.

Introduction

This is a little toy project I did because we had an application that required a number of simple images described as vectors. This was the editor I created to allow me to create and modify these simple images. The output files can be included as resources and used by my Polygon Drawing Class. (Actually, the polygon class is not used in this application, because I created it before I created the polygon class).

I thought it would provide an interesting example of programming techniques, and in any case it makes my polygon class a bit more usable.

The idea is that there is a 100 ×100 grid, with origin in the center at 0,0 and coordinates ranging ±50, and all images are drawn within this grid. They may be scaled later. There are controls for scaling and rotating the image. 

The use is fairly obvious for the most part. The standard file menu allows you to create, save, or open vector files. The vector is stored as a vertex list. There are two arrow keys next to the image list that allow you to rearrange the points.

The points are editable; clicking twice (not double-clicking) on a point makes it directly editable. The effects will be seen when you hit Enter or select out of the item.

There are four arrows that modify the list by adding or subtracting 1 from the x or y axis to move the image left, right, up, or down.

You can type in a new point and click the Add button, and it will be added following the current selection (if there is no selection, it is added at the end of the list).

Clicking the mouse in the drawing will transfer the mouse coordinates to the input box. Double-clicking the mouse in the drawing will also perform an Add operation. What I do is click in the approximate areas I want, then clean it up doing hand-editing. Nothing deep, but it greatly simplified the creation of a number of scalable "icons" for a graphical representation of moving objects.

Selecting a point in the point list will highlight that point in the drawing with a small red circle. The Delete button deletes the currently selected point. File | New deletes all the points.

Image 1

Here's a little submarine icon I drew in about seven minutes. It is shown rotated 20°. Note the small red circle at the bottom that represents the highlighted point. I turned the grid off to get a clearer image.

Image 2

The views expressed in these essays are those of the author, and in no way represent, nor are they endorsed by, Microsoft.

Send mail to newcomer@flounder.com with questions or comments about this web site.
Copyright © 2001 All Rights Reserved

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Retired
United States United States
PhD, Computer Science, Carnegie Mellon University, 1975
Certificate in Forensic Science and the Law, Duquesne University, 2008

Co-Author, [i]Win32 Programming[/i]

Comments and Discussions

 
GeneralVery cool toy project when someone else paid you to do it!!! Pin
WREY7-Jun-02 23:09
WREY7-Jun-02 23:09 
I was the one who PAID you, Newcomer, to write that very cool toy project, and because I TRUSTED YOU, I didn't ask you to sign a "Non-Disclosure Agreement". Consequently, you took my money and the work you did, and posted it on the internet without even as much as showing a scrap of decency in you, to ask if it was OK for you to post it before you did.

I didn't have you sign a NDA because I TRUSTED and RESPECTED YOU!!!! I thought you were a BETTER person than you have shown yourself to be!!!! MY MISTAKE!!!!

Now you know why my respect for you has dropped to ZERO!!!!

People like you do not deserve RESPECT, Newcomer!!!!


William
GeneralRe: Very cool toy project when someone else paid you to do it!!! Pin
Jörgen Sigvardsson10-Jun-02 0:54
Jörgen Sigvardsson10-Jun-02 0:54 
GeneralRe: Very cool toy project when someone else paid you to do it!!! Pin
WREY10-Jun-02 7:53
WREY10-Jun-02 7:53 
GeneralRe: Very cool toy project when someone else paid you to do it!!! Pin
Jim A. Johnson10-Jun-02 8:15
Jim A. Johnson10-Jun-02 8:15 
GeneralRe: Very cool toy project when someone else paid you to do it!!! Pin
WREY10-Jun-02 15:59
WREY10-Jun-02 15:59 
GeneralRe: Very cool toy project when someone else paid you to do it!!! Pin
R10-Jun-02 21:47
R10-Jun-02 21:47 
GeneralRe: Very cool toy project when someone else paid you to do it!!! Pin
WREY10-Jun-02 22:16
WREY10-Jun-02 22:16 
GeneralRe: Very cool toy project when someone else paid you to do it!!! Pin
R10-Jun-02 23:05
R10-Jun-02 23:05 
GeneralRe: Very cool toy project when someone else paid you to do it!!! Pin
WREY11-Jun-02 0:54
WREY11-Jun-02 0:54 
GeneralRe: Very cool toy project when someone else paid you to do it!!! Pin
Jim A. Johnson11-Jun-02 4:17
Jim A. Johnson11-Jun-02 4:17 
GeneralRe: Very cool toy project when someone else paid you to do it!!! Pin
WREY11-Jun-02 10:49
WREY11-Jun-02 10:49 
GeneralRe: Very cool toy project when someone else paid you to do it!!! Pin
12-Jun-02 3:28
suss12-Jun-02 3:28 
GeneralRe: Very cool toy project when someone else paid you to do it!!! Pin
WREY12-Jun-02 10:22
WREY12-Jun-02 10:22 
GeneralRe: Very cool toy project when someone else paid you to do it!!! Pin
sharp_k27-Jul-07 5:44
sharp_k27-Jul-07 5:44 
GeneralExcellent! Pin
Stefan Spenz6-Jun-02 4:36
Stefan Spenz6-Jun-02 4:36 
GeneralNicely Done Pin
Ed Gadziemski6-Jun-02 3:41
professionalEd Gadziemski6-Jun-02 3:41 
GeneralVery cool! Pin
Alexander Wiseman6-Jun-02 2:16
Alexander Wiseman6-Jun-02 2:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.