代写C代码 代做C程序 C辅导 C家教

远程写代码 Debug 讲解答疑 不是中介,本人直接写

微信: ittutor QQ: 14061936 Email: ittutor@qq.com

导航

 

The objective of Assignment 2 is to provide the students an opportunity to gain experience in the 
design of Windows based applications using Microsoft Visual C++ 2008.  
 
The lecturer of ELEC362 will allocate one of the project specifications to you.  
 
You are asked to submit a formal report detailing the design and structure of the program and 
a CD containing all files for a working program.  
 
The submission deadline is 4pm, Friday, 6th
 May 2011): 
 
You report should include the following sections: 
1.  Section 1: Introduction 
An  introduction  to  the objectives of  this assignment and an analysis of  the project specification 
with  a  focus on  the  functionality of  the program. The original problem  specification  should  be 
included in the report as an appendix. 
 
2.  Section 2: Methodology and Implementation 
Detailed description of any mathematics or physical mechanisms  that are  to be  implemented  in 
the event handlers and how they are implemented using code extracted from the event handlers in 
your Form1.h file. Your explanation should be clear and concise. Use properly typed equations if 
necessary. All variables or symbols must be explained when they appear in the report for the first 
time. 
 
For example, if your program is to convert the pixel colour into a temperature value, what would 
be the conversion method? You will need to use three variables, such as r, g, and b, to represent 
the  three  colour  components  of  a  pixel  and  give  an  equation  or  formula  to  describe  the 
relationship between the colour and the temperature. 
 
If your program  is  to read  the values from a curve on an  image, what would be  the relationship 
between  the  pixel  position  coordinates  and  the  value  of  the  physical  quantity,  taking  into 
consideration of the type of axis, such as a linear axis or logarithm axis?  
 
If  your  program  is  to  read  four  points  from  an  image  and  use  the  points  as  corners  of  a  new 
quadrilateral user control, then you will need to describe the important data members, events and 
function members of the new control, and explain how you are going to implement the properties 
in the new user defined control.  
 
If your program needs to write the values of the data members of a class  to a data file, how you 
are going to organise the data in the disk file and how your program reads the data from a file to 
update the properties of a class? 
 
3.  Section 3: GUI Design and Role of Event Handlers 
Detailed  explanation  of  your  design  of  the  GUI  and  how  the  GUI  can  be  used  to  meet  the 
functionality required by the specification. For example, if you click a button on the GUI, what is 
going to happen?  Also  give  necessary  screenshot  captured  when  your  program  is  running  to  demonstrate  that 
output  from  your work. Describe  the properties  that  you need  to  set or  change  for  each of  the 
components  in  your  application  and  clearly  show  in  which  event  handlers  the  properties  are 
changed or updated. You can use a table to present the information in an organised manner.  
 
4.  Section 4: Source Code 
 
Hard copy of programme code that contains definition of data members, function members of the 
Form1 class and all event handlers. Give sufficient comments so a reader can easily understand 
what you intend to do for each of the variables or event handlers in the form1.h file.   
 
Also  provide  a  description  at  the  beginning  of  each  event  handler  to  describe  its  overall 
functionality. You can  copy  the code  into a Word document,  format  the code  in  an easily  read 
style, and then add text comments to explain the code.  
 
5.  Summary of Your Work 
Does your program work? What  test you have done  to prove  that  it words? Does  it meet all  the 
requirements? What  difficulties  you  have  had  in  the  design  and  coding  stage?  If  you  did  not 
finish the project, what is the reason? 
 
 
 
CD: 
The submitted disk must contain all project files and folders. Your code will be examined through the 
following steps. It the code on the CD does not work, you will lose marks. You are advised to check 
the CD yourself following the steps below before you submit it. 
 
o  Step 1. Copy  the whole project folder from your CD to as  local drive on a machine running 
Visual C++ 2008.  
o  Step 2. Change the file attributes from ready-only to a suitable attribute so the files could be 
edited. This is necessary during the compilation stage. 
o  Step 3. Compile your project. 
o  Step 4. Run your program to test its functionalities. Specification 1: Temperature reading 
 
Computer based simulation of engineering systems or natural phenomenon normally produces a large 
amount of data. Extracting information from this huge amount of data and presenting the information 
in a suitable form to the user could be extremely time-consuming and challenging. An effective way 
to do  this  is  required. One possibility  is  to visualise  the data using colour contour maps. A contour 
map  is  one  using  different  colours  to  represent  different  values  of  a  quantity  in  two  dimensional 
domain. 
 
In this specification, a Windows based program is to be developed to meet the following requirement. 
An image for this specification is available from the VITAL site. On the given colour map, there is a 
colour scale to relate each pixel (other than a while pixel) to a temperature range. 
 
1.  The program should have a user friendly GUI. A good GUI should have pleasant colour for 
the controls and the functionality of each control can be easily understood. There should not 
be much of the space on the Form that is wasted (i.e. not occupied by controls or not used to 
display information).  
2.  The user  is  allowed  to  select  a bmp  file  from  a hard disk  and  the program will display  the 
image on the GUI (considering using an OpenFileDialog control to open the file) 
3.  With a  selection button,  the  image  can be  shown  in  its  real  size or  scaled  to  fit  the display 
window (Picture box). When displaying the image in its real size, different part of the image 
can be viewed by clicking the image and move it around in the picture box. 
4.  When  a  button  is  clicked,  functionality  is  activated  to  track  the  temperature  range  at  the 
cursor position, and the result is shown in a text box or on a panel. The unit of temperature is 
K. 
5.  The colour  scale provided on  the  image  file  should be used  for establishing  the  conversion 
method  between  colour  and  temperature.  There  are  14  colour  patches  on  the  image.  Each 
patch indicates a small range of temperature. If a colour is out of the range of the colour scale, 
such as white or black, show N/A in the text box or panel. 
6.  When  your  program  meets  the  requirement  listed  in  1  –  5,  you  should  have  a  working 
program. Now considering the issue that if the size of the GUI is changed, how can the image 
display window  also  change  proportionally  according  to  the  new  size  of  the GUI? Modify 
your program  to demonstrate your  ideas. You are advised  to make a copy of  your program 
resulting  from  steps 1  to 5 before  you  start  step 6. This  can be done by  copying  the whole 
project folder to another location on your hard disk.  
7.  Based on your understanding of  the colour models, produce a method  that can visualise  the 
temperature with more  resolution,  i.e. with more  than  14  colour  patches.  Draw  your  new 
colour patch at the bottom of the GUI on a panel to check if you can visually differentiate the 
colours for different temperatures in the range from 300K to 30000K. 
 
A sketch for Specification 1. This is only for you to have some initial ideas of the GUI. Your design 
could be different from this diagram.    
Specification 2: Colour to grey scale converter 
 
In  publishing  scientific  results,  it  is  often  necessary  to  convert  a  colour  image  into  a  good  quality 
grey  scale  image. Most commercial  imaging programs use very  simple methods  for  the conversion 
and the resultant grey scale image usually has the same grey scale intensity for red and blue colours 
for example. This will result in a great lose of information during the conversion. A Windows based 
program  is  to  be  developed  to meet  the  following  requirement. An  image  for  this  specification  is 
available from the VITAL site. 
 
1.  The program should have a user friendly GUI. 
2.  User  is allowed  to select a bmp file from  the hard disk and  the program will display  the 
bmp file on GUI (considering using an OpenFileDialog control) 
3.  With a  selection button,  the  image can be  shown  in  its  real  size or  scaled  to  fit  into  the 
image window (picture box). 
4.  When a button is clicked, functionality should be activated to convert a colour image to a 
grey scale image and the result be shown in another picture box for comparison.  
5.  The grey scale  image can be saved  to hard disk when a button  is clicked. The file name 
should be provided by the user in a SaveFile dialog box. 
 
6.  In  the colour  image,  the colour changes  from blue  to  red  represent  temperature changes 
from a low value to a high value. In the grey scale image, the image needs to be from dark 
to bright. You will need  to research and decide the starting and ending grey scale for the 
overall  temperature  range.  If you  simply use  the average of  the  three colour component 
R,G,B as  the grey scale, you will  likely fail your assignment 2 because with  this method 
blue and red will have similar grey scales. So think carefully about the conversion method 
between colour and greyscale. It is an important part of the assignment. You can consider 
to use the hue of the colour as an intermediate parameter in the conversion. 
 
7.  A grey scale  reference patch  in  the  resultant  image will replace  the original colour scale 
patches  after  you  finish  the  conversion. A user will need  to make  reference  to  the grey 
scale patches when viewing the image for information of the value of the quantity that the 
image  represents,  such  as  temperature..  One way  to  test  if  your  conversion method  is 
satisfactory is to look into the grey scale patches to see if you can clearly differentiate the 
grey patches.  If  you cannot, you will need  to optimise  the conversion  scheme. You can 
still  use  a  24  bit  bmp  image  to  store  your  resultant  image  by  equalling  the  RGB 
components.  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
Specification 3: Electronically reading a diagram on paper 
 
Curves  are most  often  used  in  scientific  journals  to  represent  experimental  or  theoretic  results. At 
many occasions  it  is necessary for a reader  to pick up values from  the curves for understanding  the 
data or using the data in research. This is however not an easy job since one will need to use a ruler 
and careful reading to obtain the value. Nowadays most journals are published in pdf format and the 
diagrams containing the curves can be easily converted into an image.  
 
In this assignment, a Windows based program is to be developed to meet the following requirement. 
A test image for this specification is available from the VITAL site. 
 
1.  The program should have a user friendly GUI. 
2.  User is allowed to select a bmp file from the hard disk and the program will display the bmp 
file on GUI (considering using an OpenFileDialog control) 
3.  With  a  selection  button,  the  image  can  be  shown  in  its  real  size  or  scaled  to  fit  the  image 
window  (picture box control).  In  the  real  size mode  the  image can be moved around  in  the 
picture box by using mouse clicking and dragging. 
 
4.  Calibration – When a button  is clicked,  the program will allow  the user  to use  the mouse  to 
select two points on each axis and use two text boxes to enter two values corresponding to the 
two points on the axis. The type of the axis can also be input by the user using a text box. The 
entered values will then be used as reference values in the calculation.  
 
5.  When a button  is clicked, functionality  to calculate  the horizontal and vertical axis values at 
the cursor point should be activated. When the mouse moves to a point on a curve (it could be 
a white pixel on a broken line), the values should be correctly shown in two text boxes or two 
panel controls.  
6.  Pay  attention  to  the  logarithm  axis  in  the  diagram  shown  below  and  use  appropriate 
mathematical formula  to obtain  the correct coordinate. Your program should be able  to deal 
with both  linear  scale  and  logarithm  scale  for  either  axis. This means  your program design 
should  be  flexible. For  example,  it  should  deal with  a  diagram with  a  logarithm  horizontal 
axis or a linear vertical axis, or a diagram with both logarithm axes.  
 
 
Diagram for Specification 3. 
  
Specification 4: Displaying 2D domain grids using a data file 
 
A Windows based program is to be developed to meet the following requirement. Two files for this 
specification are available from the VITAL site. The first one is an explanation of the structure of the 
data  file  and  the  second one  is  the original  file  containing  the  results which  is  to be  read by  your 
program. 
 
Hint: one way to do this is to create a blank bmp image using a scale parameter indicating how many 
pixels per meter, based on the axial and radial size of the domain which can be decided after you read 
the data from the file. You can then display this bitmap image in a picture box. 
 
1.  The program should have a user friendly GUI. 
2.  User is allowed  to select a data file from a hard disk and  the program will open  the file, 
read  the data  into  the program and display  the grids. To do  this you will need  to use an 
OpenFileDialog control to open the file. 
3.  A description to the structure of the file is given in a word file and the original data file is 
given as a  text  file. You will need  to  read  the word document carefully before you start 
the design. Your program should be able to perform 
  Displaying  the domain with  cell division  in  a picture box  (similar  to  the one  shown 
below). 
  Display in text boxes how many cells in the radial direction and how many cells in the 
axial direction, and the axial and radial size of the whole domain. The number of cells 
is given in the first line of the text file. 
  A  scale  parameter  can  be  set  via  a  text  box  to  specify  how many  pixels  per meter 
when you create the bitmap image. 
  If the user enters the axial cell position and radial cell position in two text boxes, the 
program  should display  the x  and  y  coordinates  of  the  lower-left  corner  of  the  cell. 
The  program  also  displays  the  average  width  of  the  cell  in  the  axial  and  radial 
directions in two text boxes.. 
  The bitmap image can be moved around in the picture box to view different part of the 
domain by mouse clicking and dragging. 
  After displaying  the grid  image,  if you move  the cursor over a pixel  in  the grid area, 
your program should decide which cell it is in and display the axial and radial position 
of the cell in two text boxes. 
 
Diagram  showing  the  division  of  cells  in  the  computational  domain  for  Specification  4.  Program 
from specification 4 should produce something similar to this diagram in the display area of the GUI.  
Specification 5: Visual simulation of a piston-cylinder system 
 
A Windows  based  program  is  to  be  developed  to  simulation  the  compression  process  of  gas  in  a 
cylinder, as shown in the figure below. The piston will stroke at a specified frequency F, for example 
one cycle every 4 seconds, giving a frequency of 0.25Hz.  
 
You can assume that the gas temperature and pressure are uniform in the cylinder volume at all times 
and their values are To and Po at its maximum volume. To and Po will be input by the user when the 
program  starts.  When  the  cylinder  volume  becomes  smaller,  the  temperature  and  pressure  will 
increase. The pressure, P, in the cylinder as a function of the cylinder volume is 
 
where Vo is the maximum volume and  = 1.4 is a constant for air. In your program you should allow 
the user  to  choose a value  for   but you can give  it a default value of 1.4. The  temperature T as a 
function of P can be described as 
 
From  the above  two equations you can work out how  temperature changes with  the volume of  the 
cylinder. You can use a reasonably small thickness for the piston head and the bottom of the cylinder. 
By “cylinder  length” we mean  the net  length of  the cylinder volume. Once  the cylinder  length and 
diameter are determined, you can calculate  the Vo,  then T and P  for user-given To and Po values. 
The stroke of the piston should be a percentage of the cylinder length, for example 70%. Think about 
in reality how the speed of the piston changes with time if it is used in the car engine. 
 
Diagram showing a piston-cylinder system 
 
Your program should meet the following requirement: 
 
1.  The  program  should  have  a  user  friendly  GUI.  The  movement  of  the  piston  should  be 
visualised on  the GUI by moving  the  two controls  representing  the  rod and  the piston. You 
can use two panels for this purpose. Think about how you can move the piston according to a 
given speed. Think about how car engines work. 
 
2.  There should be two text boxes on the GUI to display the length and diameter of the cylinder. 
User is allowed to change the diameter and length of the cylinder and the stroke of the piston 
as a percentage of the cylinder length, and the frequency.  
 
3.  The user can choose to display T or P of the gas in the cylinder volume. You should work out 
a colour scale that will change the colour of the cylinder volume from blue (minimum T or P) 
to red (maximum T and P) as a function of T or P. 
 
4.  The instant value of the T and P should be shown in two text boxes when the piston moves. 
 
5.  There should be a button to hold the movement of the piston when it is clicked. If it is clicked 
again, the piston will continue to move. 

相关推荐