Next Previous Contents

5. DataViewer applications

This section introduces the basic notions to run and to create a DataViewer application.

5.1 Running a DataViewer application

To run a DataViewer application, you should run the following command:


DV.py python_script.py

The first argument is the name of the DataViewer executable. If it is not in the current directory, it must be preceded by the path. For example, if we were in the directory ~/Dataviewer/Python_demo_simple , instead of DV.py we should type /bin/DV.py. The executable of DataViewer always has this name.

The second argument is the name of a Python script which contains the object (scene) we want to view with DataViewer. For example, from the same directory, we would type /python_script/typein.py. This argument must only end with .py.

For more details on running DataViewer, see the DataViewer's User Guide.

5.2 Writing a DataViewer application

A DataViewer application consists in a Python script and a c++ function that communicate by means of strings.

The Python script

Write a Python script defining a class derived from GeomWindow. In this class, you must define two methods:

In this methods, you must declare the widgets that are necessary for your problem. These widgets will be included in a dialog window that is activated from the File/User menu.

In this method, you must specify the c++ problem the following way:

self.geom.set_problem("problem_name")

and you must send all the information needed by the c++ function with

self.geom.file("some data string")

The c++ function

Write a c++ function that constructs the scene graph for your problem.


int problem_function(DVcreate_image_arguments )

This function must always return the int type, and must always take an argument of type DVcreate_image_arguments.

Two things are important about this argument:

Finally, to link the Python script with the c++ function, you must proceed the following way:


Next Previous Contents