You are on page 1of 20

*

GRAPHICS EDITOR
BY:

MD SAADULLAH
&
SHRIDHAR S PARAGOND
1.1 General Introduction

Graphics provides one of the most natural means of communicating with a computer, since our highly developed 2D and 3D pattern-recognition
abilities allow us to perceive and process pictorial data rapidly and efficiently. Interactive computer graphics is the most important means of producing
pictures since the invention of photography and television. It has the added advantage that, with the computer, we can make pictures not only of concrete real
world objects but also of abstract, synthetic objects, such as mathematical surfaces and of data that have no inherent geometry, such as survey results.
Using this editor you can draw and paint using the mouse. It can also perform a host of other functions like drawing lines, circles, polygons and so on.
Interactive picture construction techniques such as basic positioning methods, rubber-band methods are used. Block operations like cut, copy and paste are
supported to edit large areas of the workspace simultaneously. It is user friendly and intuitive to use.
Graphics Editors can normally be classified as:

 2D Graphics Editors.
 3D Graphics Editors.

A 2D Graphics Editor is used to draw 2D primitives (Line, Rectangle, Circle, Ellipse, etc. and alter those with operations like cut, copy and paste.
These may also support features like layers and object precision etc. A simple 2D Graphics Editor should include the following features:
 Facilities: Cursor Movement, Editing picture objects
 Good User Interface: GUI / Toolbars / Icon based User Interface.
A 3D Graphics Editor refers to program used to create 3D computer-generated imagery. There are typically many stages in the
"pipeline" that studios use to create 3D objects for film and games. Many 3D modelers are general-purpose and can be used to produce
models of various real-world entities, from plants to automobiles to people. Some are specially designed to model certain objects, such as
chemical compounds or internal organs.

3D modelers are used in a wide variety of industries. The movie industry uses them to create and manipulate characters and objects
for animated and real-life motion pictures. The video game industry uses them to create assets for video games. The science sector uses them
to create highly detailed models of chemical compounds. The architecture industry uses them to create models of proposed buildings and
landscapes. The engineering community uses them to design new devices, vehicles and structures as well as a host of other uses.

1.2 What Is OpenGL?

OpenGL is strictly defined as “a software interface to graphics hardware.” In essence, it is a 3D graphics and modeling library that is
highly portable and very fast. Using OpenGL,

you can create elegant and beautiful 3D graphics with exceptional visual quality. The greatest advantage to using OpenGL is that it is orders of
magnitude faster than a raytracer or software rendering engine. Initially, it used algorithms carefully developed and optimized by Silicon Graphics,
Inc. (SGI), an acknowledged world leader in computer graphics and animation. Over time, OpenGL has evolved as other vendors have contributed
their expertise and intellectual property to develop high-performance implementations of their own.
OpenGL is not a programming language like C or C++. It is more like the C runtime
library, which provides some prepackaged functionality.
OpenGL is intended for use with computer hardware that is designed and optimized for the display and manipulation of 3D graphics.
Software-only implementations of OpenGL are also possible. However, using a software implementation means that your program can potentially
run on a wider variety of computer
systems that may not have a 3D accelerated graphics card installed.
OpenGL is used for various purposes, from CAD engineering and architectural applications to modeling programs used to create
computer-gene
1.3 Problem Statement
The objective is to build a graphics editor having all required operations that a normal graphics editor should offer. The coding is implemented
for a single canvas graphics editor. In this editor importance is given to a simple user interface and implementation of all basic graphic routines and basic
graphic editing options.
The basic requirements of the graphics editor were analysed to be:

1. User Interface- The presentation of the graphics editor is crucial to its acceptance by its users. The package should provide easy selection
and implementation of the features through iconic interfaces.
2. Color Selection - To select a suitable color for drawing the primitives. The editor implements support for drawing various shapes mentioned
above.
3. Graphics Drawing – To draw basic primitives like line, circle, rectangle on the canvas and to use tools like pencil, colour filling, eraser, etc.
to
manipulate the image.
 Line: line is drawn by selecting two points start point and the end point. The start point begins with mouse click and end point is the
point where mouse button is released.
 Circle: Circle is drawn by selecting a point and dragging thereafter till the desired radius.
 Text: selecting the text icon and thereafter entering the text from keyboard
 Rectangle: rectangle is drawn by selecting a start point and dragging to end point of required size.
 Freehand Drawing: a freehand drawing is the one in which wherever mouse is dragged pixels are plotted

Other features:
 Fill Shapes: this is done by selecting a co-ordinate by click of mouse and the enclosed area of the point is filled with the selected color.
 Eraser: this feature allows deleting particular portions of figure as selected by click of the user.
 Dialog boxes: Dialog boxes and menus add user friendliness to the package.
FLOW CHART of Project
H3.1 Introduction
1. Product Perspective:
This is a graphics editor that enables the user to input graphical data. Using the editor, the user can also save the information input by him/her
into files or open existing files for editing. This editor provides a graphical user-friendly interface to create and edit the files. In keeping with the low-
end users, help files have been provided for each of the actions.

2. Product Functions:
As mentioned previously, the main objective of the editor is to help the user to input graphical data and edit it conveniently. For ease in input and
to help the user to traverse through the text easily, the editor provides functionality through the mouse.

3. User Characteristics:
The editor provides a very easy-to-use interface and does not expect any extra technical knowledge from the user. A basic understanding of all the
options provided in the editor would facilitate him in using the editor to the best possible extent. Since it is a mouse-driven interface if is sufficiently
easy for any kind of end user to run it.

2. General Description
1. General Constraints:
 The software is being built on the concept of interaction with windows, efficient use of the memory is very important.
 As the software needs to be run even on low-end machines the code should he efficient and optimal with the minimal
redundancies.
 Needless to say, the editor should also be robust and fast.
 It is assumed that the standard output device, namely the monitor, supports colors.

2. Assumptions and Dependencies:


 The user's system is required to have the VC++ compiler of the appropriate version.
 The system is also expected to have a mouse connected since most of the drawing and other graphical operations implemented assume the
presence of a mouse.

2. Software Requirements
The editor has been implemented by using the glut library for interfacing with window system and mainly requires an appropriate version of the
compiler to be installed and functional. Though it has been implemented by using VC++, it is pretty much platform independent with the restriction that
there is support for the execution of CPP files.
Operating System : Windows 2000 | XP|Vista
Complier : Microsoft® Visual Studios Visual C++ compiler

3.4 Hardware Requirements


The standard output device is assumed to be a color monitor. It is quite essential for any graphics package to have this, as provision of color
options to the user is a must. The mouse, the main input device, has to be functional. A keyboard is also required.
Apart from these hardware requirements, there should be sufficient hard disk space and primary memory available for proper working of the
package.
Processor : Pentium III or higher RAM
: 128MB or more.
*
Proposed System :
To achieve three dimensional effects, OpenGL software is proposed. It
is software which provides a graphical interface. It is an interface
between application program and graphics hardware.
The advantages are:

* OpenGL is designed as a streamlined.


* It is a hardware independent interface, it can be implemented on
many different hardware platforms.
* With OpenGL, we can draw a small set of geometric primitive such as
points, lines and polygons etc.
* It provides double buffering which is vital in providing transformations.
* It is event driven software.
* It provides call back function.
*
* 6.1 Working With The Window System
* 6.1.1 glutInit
* glutInit is used to initialize the GLUT library.
*
* Usage
* void glutInit(int *argcp, char **argv);
* argcp A pointer to the program’s unmodified argc variable from main. Upon return, the value pointed to by argcp will be updated, because glutInit
extracts any command line options intended for the GLUT library. argv The program’s unmodified argv variable from main. Like argcp, the data for
argv will be updated because glutInit extracts any command line options understood by the GLUT library.
*
* Description
* glutInit will initialize the GLUT library and negotiate a session with the window system. During this process, glutInit may cause the termination of
the GLUT program with an error message to the user if GLUT cannot be properly initialized. Examples of this situation include the failure to
connect to the window system, the lack of window system support for OpenGL, and invalid command line options. glutInit also processes
command line options, but the specific options parse are window system dependent.
*
* 6.1.2 glutInitWindowPosition, glutInitWindowSize
* glutInitWindowPositionand glutInitWindowSizeset the initialwindow position and size respectively.
* Usage
* void glutInitWindowSize(int width, int height);
* void glutInitWindowPosition(int x, int y);
* width Width in pixels.
* height Height in pixels.
* x Window X location in pixels.
* y Window Y location in pixels.
*
* Description
* Windows created by glutCreateWindow will be requested to be created with the current initial windowposition and size. The initial value of the
initial window position GLUT state is -1 and -1. If either the X or Y component tothe initial window position is negative, the actual window
position is left to the window system to determine.
*
* 6.1.3 glutInitDisplayMode
* glutInitDisplayMode sets the initial display mode.
*
* Usage
* void glutInitDisplayMode(unsigned int mode);
* mode Display mode, normally the bitwise OR-ing of GLUT display mode bit masks. See values below:
* GLUT RGBA Bit mask to select an RGBA mode window. This is the default if neither GLUT RGBA nor
* GLUT INDEX are specified.
* GLUT RGB An alias for GLUT RGBA.
* GLUT SINGLE Bit mask to select a single buffered window. This is the default if neither GLUT DOUBLE or
* GLUT SINGLE are specified.
* GLUT DOUBLE Bit mask to select a double buffered window. This overrides GLUT SINGLE if it is also specified.
* GLUT DEPTH Bit mask to select a window with a depth buffer
*
*
*
* 6.1.4 void glFlush()
* Forces any buffered OpenGL command to execute.
*
* 6.1.5 void glViewport(int x,int y,GLsizei width,GLsizei height)
* Specifiesa width*height viewport in pixels whose lower-left corner is at(x,y) measured from the origin of the window.
*
* 6.1.6 void glutMainLoop()
* Cause the program to enter an event-processing loop. It should be the last statement in main.
*
* 6.1.7 void glutDisplayFunc(void (*func)(void))
* Registersthe display function func that is executed when the window needs to be redrawn.
*
* 6.1.8 void glutPostRedisplay()
* Requests that the display callback be executed after the current callback returns.
*
*
* 6.2 Specifying Simple Geometry
*
* 6.2.1 void glVertex[234][sifd](TYPE xcoordinate,TYPE ycoordinate,…)
* void glVertex[234][sifd](TYPE *coordinate)
*
* Specifies the position of a vertex in 2,3or 4 dimensions. The coordinates can be specified as shorts s, ints i, floats f, or doubles d. If the v is
present , the argument is a pointer to an array containing the coordinates.
*
* 6.2.2 void glBegin(glEnum mode)

*
* Initiates a new primitive of type mode and starts the collection of vertices. Values of mode include GL_POINTS, GL_LINES, GL_POLYGON,
GL_LINE_LOOP, GL_TRIANGLES.
*
*
*
* 6.2.3 void glEnd()
* Terminates the list of vertices.
* 6.3 Input Device and Interaction
* 6.3.1 Menu
* GLUT supports simple cascading pop-up menus. They are designed to let a user select various modes within a program. The
functionality is simple and minimalistic and is meant to be that way. Do not mistake GLUT's pop-up menu facility with an attempt to
create a full-featured user interface. It is illegal to create or destroy menus, or change, add, or remove menu items while a menu (and
any cascaded sub-menus) are in use (that is, popped up).
* The popup menus can be arranged in a hierachy of menus, sub-menus, sub-sub-menus, and so on. Since a sub-menu identifier must be
passed as an argument to the GLUT functions that create the parent menu, the menu must be created from the bottom up. For example,
assume we want to create a main menu with entries Option A or Submenu1, where the sub-menu has entries of Options B, C, or
Submenu2, where the sub-sub-menu has Options D and E.
* Submenu identifiers must be declared for each of our menu entries. This is a unique integer value will be assigned as the menus are
called by glutCreateMenu(). Start with the lowest level menu and pass as an argument the callback function, menuCB, which defines
menu selection options. To create the lowest level menu and its entries:
* int sub2 = glutCreateMenu(menuCB);
* glutAddMenuEntry("Option D", 4);
* glutAddMenuEntry("Option E", 5);
* Then go up one more level and do the same thing for Submenu1:
* sub1 = glutCreateMenu(menuCB);
* glutAddMenuEntry("Option B", 2);
* glutAddMenuEntry("Option C", 3);
* glutAddSubMenu("SubMenu2", sub2);
*
*
* Finally, we need to go the same thing for the highest level menu:
* glutCreateMenu(menuCB);
* glutAddMenuEntry("Option A", 1);
* glutAddSubMenu("SubMenu1", sub1);
* glutAddMenuEntry("Quit", 6)
*
* These menu options can now be used in the callback function menuCB to process the users
*
* menu choice.
* void menuCB(int item)
* {
* switch (item) {
* case 1:
* / do whatever option A does
* break;
* case 2:
* / do whatever option B does
* 6.3.2Mouse
* glutMouseFunc
* glutMouseFunc sets the mouse callback for the current window.
* Usage
* void glutMouseFunc(void (*func)(int button, int state,
* int x, int y));

* func The new mouse callback function


*
Conclusion And Future Enhancements

This graphics editor is very user friendly tool. The user can very easily use this tool to draw or manipulate a drawing. The interface is mouse driven
and the user can select a function by clicking on an icon representing that function.

For the user’s help the function performed by each icon is displayed in the status bar as soon as the mouse pointer moves over the icon. We have
tried our best to make this editor very realistic, so that the user does not face any trouble when switching over from any real life graphics editor to this
highly useful one.

The following are some of the features that are planned to be supported in the future versions of the graphics editor.
 Features like "Undo" and "Redo " could be provided.
 The editor can be made to save images in standard image file formats such as bmp, jpeg, gif. Therefore Support for different file formats like
bmp, jpeg, gif etc. could be provided.
 Support for advanced 3d drawings and transformations.
 Only Single Document Interface (SDI) has been provided, multiple document interface can be provided.
SNAP SHOT of project
We have obtained information from many resources to design and implement our
project successively. We have acquired most of the knowledge from related
websites. The following are some of the resources :

Textbooks:
1. Interactive computer graphics-Edward angel,2nd edition,Addison-welsey,2000
2. F.S.Hill,jr.:computer graphics using OpenGL,2nd edition,pearson education,2001
3.James.d.Foley,Andries Van Steven K Feiner,F.Hughes,computer graphics,Addisson-
wesley,1997 cc
[1]. Edward Angel: ”Interactive Computer Graphics A Top-Down Approach with OpenGL”, 5th Edition, Pearson
Education , .Addison- Wesley,2008.
[2]. F.S. Hill, Jr.: “Computer Graphics Using OpenGL”, 2nd Edition, Pearson Education,2001.

[3]. James D Foley, Andries Van Dam, Steven K Feiner, John F Huges,

”Computer Graphics”, Addison-Wesley 1997.

[4]. Donald hearn and Pauline Baker: Computer Graphics-OpenGL Version ,2nd Edition

[5]. Yashavant Kanetkar, “Let us C++”, BPB Publications (1991)


[6]. www.wikipedia.org.

You might also like