Difference between revisions of "Programmatic depiction of objects in tomograms"

From Dynamo
Jump to navigation Jump to search
Line 60: Line 60:
 
==== Lines ====
 
==== Lines ====
  
Use the command <tt>line</tt>
+
Use the command <tt>line</tt> for simple lines between two points.
  
 
== Tomogram slices ==
 
== Tomogram slices ==

Revision as of 14:46, 8 March 2017

This article describes some technique for generation of tomogram scenes.

While we call the different objects as "matlab-"XX, all the following explanations apply to the Dynamo command line, which inherits the graphic functionality of matlab.

Example of programmatically created scene

Basic tool: graphic handles

The basic objects that we will use are the matlab figure and the matlab axis. Roughly speaking, a Matlab figure is a window generated by Matlab. A Matlab axes is a system of coordinates that can be defined inside a figure, and which can contain graphical objects.

In other words, graphical objects are defined into a canvas (a Matlab axes), which is parented by a window (a Matlab figure);

Matlab figure

A matlab figure can be created just by the order;

f = figure();

Here, f</ff> is an arbitrary name,we could have called the figure any other name. Once created, this f offers a handle, i.e., a way to operate on the figure. For instance :

f.Name = 'This is my figure'

will change the name shown on the top bar of the figure.

The current figure

One can get a handle to the current figure (the last one to have been active) through the command gcf. If none is current, a new figure will be generated.

Matlab axes

A newly created figure will contain by default an axes object. The current axes can be captured through the gca command and get a handle assigned:

ax = gca

so that in the next commands we can use the variable ax to refer to the handle.

In tomography, we are normally interested in having the same scale for the x,y and z coordinates. To force an axes called ax to behave this way, we use: axes(ax,'equal');

Graphical objects

Matlab provides many primitives for depiction of 3d objects. Besides generating a graphical object, most of them will return a handle that represents the created object, and that can be used later to edit and manipulate it.


Clouds of points

If you have three vectors x,y,z you can depict them as a set of 3d coordinates with:

 h = plot3(x,y,z,'o');

In order to make explicit in which axes you want to generate the plot, you can pass the flag 'Parent', for instance:

 h = plot3(x,y,z,'o','Parent','ax');

The handle h allows you to change properties in the graphics, for instance:

 h.MarkerSize = 12 

will enlarge the size of the circle markers generated by the original order.


Lines

Use the command line for simple lines between two points.

Tomogram slices

The class dpktomo.volume.slices.Slice is used to generate objects that can read oblique slices from inside a tomogram. The class dpktomo.volume.slices.SliceGraphic is used to generate the graphic representation of the slice.

(Examples will be posted, contact us if you need this functionality)

Models

Models have different plotting methods attached.

Standard plotting methods

The standard plotting methods are called plotXX, where XX can be Points, TablePoints

The regular syntax of a plotting method is:

 object.method( axeesHandle)

Thus, if you want to use the method plotPoints to generate in a graphical axes ax a 3d depiction of the points contained inside a model called m, your syntax would be:

 m.plotPoints(ax);