You are on page 1of 6

Міністерство освіти та науки України

Національний університет “Львівська політехніка”


Інститут комп’ютерних наук та інформаційних технологій
Кафедра автоматизованих систем управління

ПРОГРАМУВАННЯ ЗА ДОПОМОГОЮ ФУНКЦІЙ


WINDOWS API
ЗБІРНИК ЛАБОРАТОРНИХ РОБІТ

Методичні вказівки
до курсу “Операційні системи”
для студентів базової вищої освіти
за напрямком “Комп’ютерні науки”

Львів - 2022
Laboratory work #9
Topic - Principles of management in software systems.
The goal is to master the general principles of effective management
of complex software systems and correct editing their software components.

THEORETICAL PROVISIONS
Editing a system is a partial case of its management, when its structure
is under the control influence. A system is imperfect if there is a governing
influence that destroys the system. Therefore, the system should be created
so that any accidental impact does not destroy it. This is achieved by
carefully dividing actions into preparatory and executive for each
subroutine, by naming any names correctly, as well as by entering the
numbering of the types of objects used. Of course, objects within each type
are also numbered. At the beginning of the entire system, the preparatory
action "create table of objects" is added.
The tabular presentation of objects improves not only the stability and
comprehensibility of the system, but also allows you to conveniently and
quickly change the objects themselves. For example: rotate object 5 around
object 3 along the X axis by an angle of Gama_X, in object 7 increase
parameter 2 by Delta_L, enter a new cylinder-type object, and so on. That
is, all operations must be performed with object numbers and their
parameter numbers. All these changes can be made not only during editing,
but also according to a certain selective scenario, if you need to display the
changes of the 3D scene over time. To do this, it is only necessary to call
the procedure for making changes according to the step of the script in the
drawing procedure after calling the "draw all objects" subroutine, the entry
of which is controlled by the script launch flag.
The system is sustainable if unsuccessful options can be corrected, and
it is more convenient to store the history of changes in the system in a
structured form. When modifying both the 3D scene and the system, all
additions to the shape type table must be added to the end of the table.
Routines that draw objects of the new type must also be added to the end of
the routine library. Then each new object or system modification will have
its own number, which is greater than the previous numbers, and it will not
be a problem to return the object table to its previous state.
If each object is represented by some data structure, it becomes
possible to include in this structure a local matrix of rotations and
movements of the object itself relative to the 3D scene. Then editing the
position of the object is reduced to editing its local matrix. To draw such an
edited object in a general 3D scene, it is necessary to multiply the local
matrix of the object by the general matrix of rotations of the scene. This can
be done using the glMultMatrixf function or using a simple matrix
multiplication algorithm. Thus, the method of editing the position of an
object will not differ from the method of changing the position of the entire
scene. The initial state of the object matrix is a unit matrix, where units are
only on the main diagonal, and which is generated by the glLoadIdentity
function, or manually loaded via glLoadMatrixf.
A software system is convenient if it is easy to manage. To manage
means to make such changes in the functioning or information content of
the system that bring it closer to the goal (in other words, to the goal of
management). So, at the basis of any management there are: a goal and
various ways of achieving it (which can be chosen according to the criteria
of effectiveness in achieving the goal). Clarification of the goal consists in
giving priority to some criteria. Convenience of management means
"understanding" of the management goal by the system and automatic
selection of the most effective way to achieve it. For example, if the user
presses the right button, then the object should move to the right, but if the
user presses the right button again, then it means that the control influence
is not enough, and the movement step should be increased, but if the user
then presses the left button, then this means that the feed step is too large
and should be reduced. Thus, the criterion of efficiency will be the number
of keystrokes.
Suppose that a user using a given software product has some goal that
he wants to achieve with the help of the given software product. For a
convenient software product, it is necessary to create a convenient and
sensitive software interface that would not require long-term training, and
would also be capable of understanding the user's goal and minimizing
management errors.
Management quality means choosing the best management action
from among many possible ones. To create a convenient interface, it is
necessary for the system itself to show possible control elements that
operate according to universal rules during the control action. For example,
to control a three-dimensional figure, you can choose certain of its control
points. The first of these points should be responsible for moving the figure
on the screen. Selecting another point is associated with changing some
other shape parameter. The main thing is the correct choice of point
coordinates so that the interface is clear and obvious. Each governing
influence must not interfere with the other. For example, a point that
changes the diameter of a cylinder should not affect its position in space.
The software product of the system is divided into control components
of various types. The subsystem of control elements is activated by an event
of a certain type, for example, by pressing the keyboard. In order to activate
a certain type of control, it is necessary to assume what is happening in the
system. For example, is the user just viewing the scene or is he editing the
shape. If he is editing a shape, then you need to know its number in order to
load and change its parameters. Further structuring of the algorithm takes
place depending on the type of shape from which these shapes begin.
Functionality and structure are interrelated concepts. A properly built
program is divided into functional fragments, the removal of which does not
destroy the program, but only limits its functionality. This means that
functions that are similar in content should be next to each other, and all
sub-functions should be located inside a functional component.
In order to create the editing functionality using the keyboard, it is
necessary to insert a fork in the event of pressing each control key (for
example, the right arrow) depending on the type of figure and the number of
the selected control point, which will be affected by this control action, as
well as a fragment, which changes the movement step depending on the
previously pressed key.
Thus, the event of pressing the keyboard can be interpreted depending
on the context of the situation and the state of this figure. For example, if it
is a cylinder, and its first control point has been selected, then the keyboard
affects the general movement of the cylinder on the screen. If the second
control point was selected on the cylinder, then the message from the
keyboard is considered as a change of the first radius. If the third point is a
change in the second radius, and if the fourth control point is a change in the
height of the cylinder.
To apply universal control actions to 3D objects of different types, you
need to universally represent all objects in the form of templates of different
types containing the parameters of these objects. The description of each
template must be added to the description of each type of object. When
creating a new 3D object, it is necessary to add a standard filled copy of the
template to the data area of the 3D scene.
One simple method of building a reliable software product is to build a
system based on a pattern that is proven and works well. To use this
programming method, you need to find similar controls in your object to the
controls in the template. Then all control actions on the model can be
automatically transferred to your object. An example that can be used as a
sample is provided on Google-Disk. The criterion for the correctness of the
3D graphics algorithm is the independence of the appearance of the 3D
scene from the sequence of objects it processes. During correctness testing,
it is necessary to interchange independent operations and components in
different ways.
Note that any scene object is controlled through a minimum number of
variables:
CURRENT_EDIT_NUMBER – the number of the current object for
editing (set by the user);
CHOOSEN_POINT – the number of the current control point of the
object (set by the user);
ADR_EDIT_OBJECT – address of the beginning of the object
(determined by the system after drawing the 3D scene). All algorithms for
changing objects and the algorithm for drawing object control points are
written on its basis.

WORK PERFORMANCE PROCEDURE


1. Add some cylinders to the 3D scene and try to switch between the
shapes (using the W key) and move them using <ALT> and the left, right,
up, down, and mouse movements.
2. On the selected cylinder, try switching between its control points
using the <S> (next point), <X> (previous point) keys, and also change the
cylinder parameters when selecting different points using the left and right
arrows.
3. Add to the functionality keys for saving and loading scene data in
the temporary file SCENE.TMP (between the DATA_SCENE: and
END_DATA_SCENE: program tags).
4. Add a key that displays the (X,Y,Z) coordinates of the selected
shape in MessageBoxA using the PRINT_ST0_EDI routine.
5. Animate the selected point when switching shapes, changing its size
from 50.0 to 5.0 using glPointSize.
6. Make a small program that displays only your name in the form of
three-dimensional shapes. To do this, find a preparation function in the
sample that prepares a list of three-dimensional shapes in the form of 3D
letters of the loaded font (wglUseFontOutlinesA) and a function that sets
the base number of the starting shape (glListBase). Use glCallLists to
display text in the drawing procedure.
7. Change the Bezier surface to a larger number of points.

CONTROL QUESTIONS
1. Why do you need the independence of the control elements in
the software system?
2. How should control elements in the software system interact?
3. Why is universality in the representation of objects necessary?
4. How to avoid errors during system development?
5. How to build a convenient software interface?

WORK REPORT FORM


The report is a document that the student has successfully completed the work.
1. The goal of work;
2. Summary of theoretical information;
3. Texts of all debugged programs with comments;
4. Answers to control questions;
5. Conclusions on the specifics of the application of the acquired knowledge
or comments on the performance of the work and methodical support.

You might also like