.. _example_coil_design_application: Coil design application example -------------------------------------------- An full-blown application demoing a domain-specific usecase with Mayavi: interactive design of coils. This is example of electromagnetic coils design, an application is built to enable a user to interactively position current loops while visualizing the resulting magnetic field. For this purpose, it is best to use object-oriented programming. Each current loop is written as an object (the `Loop` class), with position, radius and direction attributes, and that knows how to calculate the magnetic field it generates: its `Bnorm` is a property, that is recomputed when the loop characteristic changes. These loop objects are available to the main application class as a list. The total magnetic field created is the sum of each individual magnetic field. It can be visualized via a Mayavi scene embedded in the application class. As we use Traited objects for the current loops, a dialog enabling modification of their attributes can be generated by Traits and embedded in our application. The full power of Mayavi is available to the application. Via the pipeline tree view, the user can modify the visualization. Familiar interaction and movements are possible in the figure. So is saving the visualization, or loading data. In addition, as the visualization model, described by the pipeline, is separated from the data that is visualized, contained in the data source, any visualization module added by the user will update when coils are added or changed. Simpler examples of magnetic field visualization can be found on :ref:`example_magnetic_field_lines` and :ref:`example_magnetic_field`. The material required to understand this example is covered in section :ref:`builing_applications`. **Python source code:** :download:`coil_design_application.py` .. literalinclude:: coil_design_application.py :lines: 32-