Lab 7 1998

Introduction

In the middle of the 18th century, a French astronomer Charles Messier specialized in finding comets. One of the problems comet hunters have is there are many objects that look "fuzzy" like comets that aren't comets. Messier's telescopes were not as good as today’s amateur scopes. Even clusters of stars appeared to be comets. His list of objects is the first list of a class of objects now classed as deep space objects. There are 110 items that have been attributed to this list either because Messier published a list with the items or because his notes indicated he knew of the item. Not all of the objects were "discovered" by Messier, but he published the list for other comet hunters. Today amateurs interested in deep space objects make the Messier list their first serious attempt at observing.

The Messier list contains many different types of objects open clusters, galactic clusters, nebulae (clouds of dust), planetary nebulae and galaxies. They have widely varying brightness (magnitude) because Messier and his friends included everything they found along a given comet's path. Objects that were not along the path of a comet during his working life were not listed no matter how bright they were. You will write a program that will find all Messier objects between two magnitudes (say 7 and 10). It will display then Messier classification (M1-M110) and magnitude as a list in order of brightness (brightest at the top) displayed in a listbox in a dialog box. The user should be able to obtain complete information about any of the items in the list box by double clicking on that item. Your program should also be able to retrieve the information about any of the objects given the M identifier. Our data file does not have location but does give constellation, type and names such as "The Wild Duck."

Design

The problem is fairly simple conceptually, but will have a number of programming challenges. First there is a file (click here) that has the number of items as its first entry and each item with is M number on the first line, magnitude on the second (as a double) and description string on the third line. This information should be read into an array and that array will be a subclass of the template class Array. This new class will have the functions necessary to solve the problem (read from a file, searches and retrieve info). The main window of your program should be a TWindow, and you will have to design a window to hold the search results. These results should also be maintained in an object of a new class (ordered array). You may want to store pointers to the original data in your main array class. This might be accomplished by passing references to the data insead of the data.

The Interface

All of the information will be gathered and distributed using dialogs. The search by M number retrieves a identifier using TInputDialog, then the information is displayed in a dialog that contains a TEdit box with tabs enabled . TEdit box tabs are set in the SetupWindow function for the dialog in exactly the same way tabs are set for listboxes.The following is the dialog I used to display search information.

This program uses list boxes and will require that you save and open files, so you may want to review the material covered in week 7 and week 12 . You will need and ordered array to store the objects in a given range and this list may be used to initialize the list box. First retrieve the magnitude range using a dialog similar to that given here.

Once you have the range retrieve all of the objects with magnitude in the requested range and insert into your ordered array. Here you could create the array then sort or use an insertion sort (insert where it belongs by overriding the insertItem function). I recommend the insertion sort since it is simple and fast in this case. You must create an instance variable for the listbox create a double click handler. Use the same dialog you used for search results to display the information. I recommend storing a copy of the ordered array in the listbox dialog class so you can retrieve the information at this point. Pass the array into the dialog constructor as a const reference. Here is my handler for this process.

void Lab7Window::cmMagitudeRange ()
{
    // INSERT>> Your code here.
    MagValDlgXfer tb;
    tb._high[0]='\0';
    tb._low[0]='\0';
   // Get the magnitude range here
    if (MagValDlg(&tb,this).Execute()==IDOK)
    {
     	int high = atoi(tb._high);
      int low = atoi(tb._low);
      OrderedMList l;
      _messiers.getMagList(low,high,l); //Get the ordered list in that range
      ArrayIterator next(l);
      MagValListXfer mTb;
      while (next)
      {
         char buff[255];
         next()->shortDescript(buff); // Get the description in the form M1    10
         mTb._mList.AddString(buff); // Add the item to the listbox transfer buffer
         next++;
      }
      MagValList(l,&mTb,this).Execute(); //Display results
    }
}

Schedule

Executable version of lab 7 click here.
The data file needed is contained in the zip file you can get by clicking here.