Lesson 5: Using the GeoCalc Dialogs

Overview

There are several dialogs included with GeoCalc that provide a graphical interface for dealing with the DataSourceComponent.  The DataBrowser, DataSourceEditor, and ObjectEditor dialogs allow the user to view and modify the DataSourceComponent and the objects it contains.  The DataSourcePicker, DatumShiftPicker, and ObjectPicker dialogs provide a graphical way to retrieve objects from the DataSourceComponent.

Since all of the GeoCalc dialogs require access to a DataSourceComponent object, we will start by creating and loading a DataSourceComponent.  For more information about using the DataSourceComponent, see Lesson 4.  

[VB]

Dim gcDataSource As New DataSourceComponent

gcDataSource.LoadFile("c:\\bmg\\GeoCalcNET\\data\\geocalc.xml")

 

[C#]

DataSourceComponent gcDataSource = new DataSourceComponent();

gcDataSource.LoadFile("c:\\bmg\\GeoCalcNET\\data\\geocalc.xml");

 

ObjectEditor Dialog

The ObjectEditor allows the user to edit a single definition within the GeoCalc DataSourceComponent.  It will not edit specific instances of objects, such as an AngularUnit that was retrieved from the DataSourceComponent with a call to GetAngularUnit; it will only edit a definition as it exists in the DataSourceComponent.

Most commonly, the user will not explicitly create and display an ObjectEditor.  The ObjectEditor dialog is used by all of the other GeoCalc dialogs to display or edit the definition of an object.  For example, when you double-click on a definition in the DataSourceEditor dialog, an ObjectEditor dialog will be displayed that shows the complete definition of the object and allows the user to edit the object.  However, it is possible for the user to manually create and display an ObjectEditor like this:

[VB]

Dim objEditor As New ObjectEditor(gcDataSource, ObjectType.ProjectedCoordSys, "BMG", "UTM-19N", Me.Handle)

objEditor.Show()

 

[C#]

ObjectEditor objEditor = new ObjectEditor(gcDataSource, ObjectType.ProjectedCoordSys, "BMG", "UTM-19N", this.Handle);

objEditor.Show();

This will create an ObjectEditor that will display and allow the user to edit the definition for the UTM 19N ProjectedCoordSys.  It is also possible to construct an ObjectEditor that will edit a new object that is not yet defined in the DataSourceComponent.  To do this, you would just omit the issuer ("BMG") and code ("UTM-19N") from the arguments list for the ObjectEditor constructor.  Here is what an ObjectEditor for the UTM 19N system looks like:

At the top of the dialog, there are two tabs, "Identification", and "Definition", which is currently selected.  The "Identification" tab contains the information that is common to all Serializable objects, like Name, Remarks, and Identifiers.  The "Definition" tab contains the information that is unique to the specific kind of Serializable object.  Therefore, the "Definition" tab looks different for each type of object that can be displayed with the ObjectEditor.

All of the objects and parameters that define the UTM 19N ProjectedCoordSys can be viewed and edited with this dialog.  For example, one could view or edit the Envelope by clicking on the "i" button next to the "Envelope" field, or one could select a different Envelope from the DataSourceComponent by clicking on the "..." button next to the "Envelope" field.  The values of the parameters that define the Projection can be edited by entering values in the "Value" fields of the table at the bottom, and the units that express these values can be changed by clicking on the button in the "Units" column of the table.

If the user clicks "OK", the dialog will be closed and any changes made in the ObjectEditor dialog will be saved to the in-memory DataSourceComponent.  In order to make the changes permanent, the DataSourceComponent will need to be saved to a file.  See Lesson 4 for information about saving the DataSourceComponent to file.  If the user clicks "Cancel", the dialog will be closed, but no changes will be made to the DataSourceComponent.

 

DataSourceEditor Dialog

The DataSourceEditor dialog is new for GeoCalc 6.3.  It provides much of the functionality that the DataBrowser dialog provides, but it has a different organization and it has the ability to search the DataSourceComponent.  In order to create an instance of the DataSourceEditor class, one must provide an instance of the DataSourceComponent and a list of the object types that will be edited by the dialog.  The dialog will be displayed when the Show method is called.  The following lines of code will instantiate and display a DataSourceEditor that will allow the user to browse and edit all of the definitions in the DataSourceComponent:

[VB]

Dim editor As New DataSourceEditor(gcDataSource, ObjectType.None, Me.Handle)

editor.Show()

 

[C#]

DataSourceEditor editor = new DataSourceEditor(gcDataSource, ObjectType.None, this.Handle);

editor.Show();

This will display a DataSourceEditor that can be used to browse and edit any definition within the DataSourceComponent.  Here is an example of the appearance of the DataSourceEditor;

The Show method will return when the user closes the DataSourceEditor dialog.  Depending on which signature of the Show method is used, the currently selected object may be returned when the user clicks OK.

 

DataSourcePicker Dialog

The DataSourcePicker dialog is new for GeoCalc 6.3.  It provides much of the functionality that the ObjectPicker dialog provides, but it has a different organization and it has the ability to search the DataSourceComponent.  In order to create an instance of the DataSourcePicker class, one must provide an instance of the DataSourceComponent and the type of the object that the dialog will be used to pick.  The dialog will then be displayed when the Show method is called.  The following lines of code will instantiate and display a DataSourcePicker that will allow the user to select from CoordSys definitions:

[VB]

Dim objType As ObjectType = ObjectType.FittedCoordSys Or ObjectType.GeocentricCoordSys Or ObjectType.GeodeticCoordSys Or ObjectType.ProjectedCoordSys

Dim picker As New DataSourcePicker(gcDataSource, objType, Me.Handle)

Dim retVal As DialogState

retVal = picker.Show(selectedObj, selectedObjType)

 

[C#]

ObjectType objType = ObjectType.FittedCoordSys | ObjectType.GeocentricCoordSys | ObjectType.GeodeticCoordSys | ObjectType.ProjectedCoordSys;

DataSourcePicker picker = new DataSourcePicker(gcDataSource, objType, this.Handle);

DialogState retVal = picker.Show(ref selectedObj, ref selectedObjType);

This will display a DataSourcePicker dialog that can be used to select a CoordSys from the DataSourceComponent.  Here is an example of the appearance of the DataSourcePicker dialog:

If the return value of the Show method is Success, then an object was successfully selected in the dialog, and s now holds a pointer to that object.  If the user closes the dialog without selecting an object, then the return value from the Show method will be Cancel.

 

DatumShiftPicker Dialog

The DatumShiftPicker dialog is new for GeoCalc 6.3.  It is similar in structure to the DataSourcePicker dialog, but it is customized to make it easy to find the DatumShifts required by a CoordTransform.  This dialog will be described in-depth in Lesson 6: Selecting DatumShifts.

 

Clean Up

Finally, we must clean up after ourselves and free the memory that was allocated in this lesson using the Dispose method:

[VB]

browser.Dispose()

objEditor.Dispose()

objPicker.Dispose()

editor.Dispose()

picker.Dispose()

If Not selectedObj Is Nothing Then selectedObj.Dispose()

gcDataSource.Dispose()

 

[C#]

browser.Dispose();

objEditor.Dispose();

objPicker.Dispose();

editor.Dispose();

picker.Dispose();

if(selectedObj != null) selectedObj.Dispose();

gcDataSource.Dispose();