This section introduces the basic notions to run and to create 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.
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:
UserWidgets
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.
Draw
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:
dv.input_string
which contains the string send by the
Python script with the self.geom.file
call;dv.top
of type DVcontainerbase
, which is the root
of the scene graph, so that any geometrical object you create must be
copied to it, or recursively copied to a container that will be directly or
indirectly copied to it.Finally, to link the Python script with the c++ function, you must proceed the following way:
problem_function
) to
DVpython_problems.h
.problem_name
) to DVpython_problems.cc, in the function
DVpython_problems
:
if(strcmp(input_problem,"problem_name")==0)
set->set_user_function(problem_function);
Makefile
. If you have taken one of the existing applications
as example, you must add your problem file to
$PROBLEM_OBJECTS
.