Subsections


Plotting in 3D

This section explains the 3D plotting functionality in SciCraft. The main concepts and terms used in this section are captured in figure 2.47.
Figure 2.47: The plot window
\begin{figure}\begin{center}
\scalebox{0.45}{\includegraphics{plotwindow_main_two_plots.eps}}\end{center}\end{figure}

The figure shows us a plot window with two render windows, plots in the render windows, and the plot window controller at the bottom. More precisely:

Plot window
is the whole window. This window will appear whenever you double click on a plot node in the module diagram.
(Plot node
is a node located under the ``Plots'' part of the node list in the main SciCraft window. When you double click a plot node in the node list, a green node will appear in your workspace. Double clicking this green node again will result in the plot window appearing.)
Render window
or Plot renderer is the area in which a plot is drawn and displayed. As you can see, a plot window can contain several render windows.
Plot
is a graphical representation and display of some data. In SciCraft a plot must reside inside a render window to be displayed.
Plot window control
is the part of the plot window that controls what kind of plots that should be displayed, and how they should be displayed. We will come back with a detailed description of the plot window control later.

When you open a plot window in SciCraft, you may notice that the user interface contain more buttons and controls than those shown in figure 2.47. These controls are disabled, but will be usable in later versions.

The plot window

As mentioned before, the plot window is the whole window containing all the other parts or elements like render windows, window controller etc. In fact, the plot window itself does not hold much logic or control, it only acts as a container for the other elements. The only things that the plot window is directly controlling are the pull-down menu and the toolbar right at the top of the window as seen in figure 2.48.
Figure 2.48: The menu- and toolbar of the plot window.
\begin{figure}\begin{center}
\scalebox{0.7}{\includegraphics{bars.eps}}\end{center}\end{figure}
The toolbar buttons are divided into three groups, and each of the buttons also has a corresponding entry in one of the pull-down menus. Some buttons also have a keyboard shortcut to make their activation easier.

File buttons

The file buttons handle file management such as saving and opening files. The buttons are listed in table 2.3 and indicated in figure 2.48.

Table 2.3: The file group buttons.
Name Button Shortcut key Description
Save \includegraphics[scale=0.6]{savebutton.eps} CTRL+S Lets you save the configuration of the plot to a file. If you find yourself configuring lots of plot windows in a similar fashion, it may be a good idea to save the configuration once, and then load the plot configuration whenever you need it. Once you have saved a configuration and restarted SciCraft, this configuration will show up in the node menu as a new plot node.
Open \includegraphics[scale=0.6]{openbutton.eps} CTRL+L Loads a plot configuration into the current plot window.
Save screenshot \includegraphics[scale=0.6]{shotbutton.eps} CTRL+G Opens a file dialogue and saves a screenshot of the active render window to the specified location and image format.



Edit and view buttons

The edit/view buttons controls the appearance of the components in the plot window such as the plot window controller and the plots. It also has buttons for removing selected (picked) elements from plots. To understand picking/selection, please refer to section 2.6.4. The buttons are explained in table 2.4.

Table 2.4: The edit/view group buttons.
Name Button Shortcut key Description
Fullscreen \includegraphics[scale=0.6]{fsbutton.eps} ALT+Return This button will toggle the plots in and out of fullscreen mode. When in fullscreen, the plot window is expanded to cover the entire screen, the window decorations are hidden and most of the pop-up menus and toolbar buttons are also hidden.
Stereo mode \includegraphics[scale=0.6]{stereobutton.eps} CTRL+3 or 3 This will toggle the render windows in and out of stereo mode. You can use this mode to view 3-D plots in stereo if you have the suitable hardware for this. If you don't have this equipment, this mode is not very useful.
Window controller \includegraphics[scale=0.6]{controlbutton.eps} None This button will toggle the plot window controller on and off. If you turn the controller off more screen space is available to the plots. If you turn it on, you can configure you plots and render windows.
Delete \includegraphics[scale=0.6]{delbutton.eps} CTRL+X Deletes all the picked elements in all plots. Refer to section 2.6.4 to understand what deleting picked elements actually mean.
Undo \includegraphics[scale=0.6]{undobutton.eps} CTRL+Z Will undo all previous deleting and bring picked elements back into the plots.



Mode buttons

The mode group of buttons have mutually exclusive functionality, meaning that only one of them can be activated at any time. These buttons control how the plots should react to mouse actions, such as clicking and movement. The modes are explained in table 2.5

Table 2.5: The mode group buttons.
Name Button Shortcut key Description
Camera mode \includegraphics[scale=0.6]{zoombutton.eps} None This mode enables you to use the mouse to pan, rotate and zoom the plots. Exactly how you do this is defined and explained under the ``Renderer Options'' menu of each render window (section 2.6.2).
Bounding box \includegraphics[scale=0.6]{boxbutton.eps} None With this mode, you can define a bounding box in a plot by pressing the left mouse button somewhere in a plot and dragging the mouse to define a red rectangle. When you release the mouse button, all the objects that are inside the rectangle, will be picked.
Pick mode \includegraphics[scale=0.6]{pickbutton.eps} P In this mode you can pick individual objects by placing your mouse pointer over an object and clicking the left mouse button. The object will then be marked as picked, and the coordinates of the picked objects will be displayed next to the mouse pointer. This mode of operation can also be used in the two previous modes. Instead of choosing the pick mode, you just place the mouse pointer over an object and press the ``P'' key.



The plot window controller

The plot window controller is central to the control of the plotting in SciCraft. It is used to customise the plot window to accommodate the specific needs of the user. As you can see from the example in figure 2.47 the plot window controller consists of several tabs, named ``Plot Setup'', ``Window 1'' and ``Window 2''. By clicking on each of these tabs in order, the plot window controller will show the contents of figures 2.49, 2.50 and 2.51 respectively.
Figure 2.49: The main setup part.
\begin{figure}\begin{center}
\scalebox{0.625}{\includegraphics{window_control_setup.eps}}\end{center}\end{figure}

In the ``Plot Setup'' tab you will see two main groups of controllers. To the left you define which input ports the plot node of this plot window should have. You add ports as desired to match the number of data sets you want this plot window to handle. To the right you can define the number of render windows to add to the plot window. As you see from figure 2.49, in this example there has been added one row of render windows. In each row there is specified two columns, resulting in two render windows side by side in the plot window. One could specify any combination of rows and columns of course, and for each render window added, a separate tab called ``Window n'' would appear in the window controller.

Figure 2.50: The setup of the first render window.
\begin{figure}\begin{center}
\scalebox{0.625}{\includegraphics{window_control_window1.eps}}\end{center}\end{figure}

Figure 2.51: The setup of the second render window.
\begin{figure}\begin{center}
\scalebox{0.625}{\includegraphics{window_control_window2.eps}}\end{center}\end{figure}

In the examples shown in figures 2.50 and 2.51 you see the setup of each of the render windows present in the plot window. As you can see from the setup, the first render window contains a three dimensional scatterplot whereas the second window contains a two dimensional scatterplot. These setup displays are known as render setups, and the plot window contains one such render setup for each render window present in the plot window. With the ``Add'', ``Delete'' and ``Renderer Options'' buttons to the left you set up each render window. The ``Add'' and ``Delete'' buttons lets you choose which plots are going to be placed inside the respective render window of the render setup. The ``Renderer Options'' button lets you adjust some common settings on the renderer window, such as background colour etc. Once you have added plots to the render window, the space to the right will be filled with the configuration options of the plots you just added.

The render window/plot renderer

Figure 2.52 shows you the first render window of the plot window in figure 2.47.
Figure 2.52: The first render window.
\begin{figure}\begin{center}
\scalebox{0.625}{\includegraphics{renderer.eps}}\end{center}\end{figure}

The plot displayed in this render window is a simple 3-D scatter plot. By clicking and moving the mouse, the plot can be manipulated in several ways, depending on the mode used. The different modes are explained in section 2.6.1. In camera mode, you can redefine how mouse actions for zooming, panning and rotation by clicking the ``Renderer Options'' button in the render setup.

It is also possible to configure some attributes of the plot displaying with some swift strokes on your keyboard. The keys and their explanation are listed in table 2.6.


Table 2.6: Shortcut keys for a render window
Key Description
3 Toggle the render window in and out of stereo mode. This will enable you to use stereo glasses on the render window. This is the same as pressing the stereo button described in table 2.4.
f Fly to the point you have picked (if any). For details on picking, see section 2.6.4.
p Perform a picking operation. This is the same as using the pick mode explained in table 2.5.
r Reset the camera used to view the plots so that it will show you the whole data set present in the render window. This is useful if you have been a little too creative with your zooming and panning for instance.
w Represent all the parts of the plots as wire frames.
s Represent all the parts of the plots as surfaces.


Notice that the render window in figure 2.52 has a red border around itself. This means that the render window was the active render window when the screenshot was taken. In a plot window you change the active render window by clicking on them. The purpose of making a render window active is to let you know which render window's render setup is displayed in the plot window controller.


Picking

Picking is quite a useful feature of plots if you are doing data analysis. What picking does is to give the user the opportunity to select or ``pick'' objects from a plot and perform operations on the selected objects. In the current version of SciCraft, the only operation supported is removing the data these objects are representing from the original data set in a limited fashion. If you pick an object in a plot you will see that the object changes colour. If there is one or more other plots open in the same plot window with the same data set dimensions compared with the plot in which the picking was done, an object will also change colour in these plots. In figure 2.53 there are two plots present, and the data set of both plots have equal dimensions (specifically, both plots have data sets with dimensions $64 \times 3$). While picking some objects in the first plot, the corresponding objects in the second plot are also marked.
Figure 2.53: Picking objects.
\begin{figure}\begin{center}
\includegraphics[scale=0.5]{picking.eps}\end{center}\end{figure}

Picked elements in a plot may be removed from the plot instantly by clicking the delete button (\includegraphics[scale=0.5]{delbutton.eps}) in the plot window's toolbar. Figure 2.54 shows the plots after the remove button has been pushed. Notice that all the yellow objects are gone. By clicking the undo button (\includegraphics[scale=0.5]{undobutton.eps}), all the removed elements will be put back into the plots, which will look like figure 2.53 again.

Figure 2.54: Picked objects removed.
\begin{figure}\begin{center}
\includegraphics[scale=0.5]{removed.eps}\end{center}\end{figure}

The plots can be regarded as a way of visualising results. So picking objects in a plot means manipulating result data, but this is usually not what a user wants. The point of picking objects is to manipulate the data set at some point in the module diagram before it is processed by a function and sent to a plot node for visualisation. In this way the manipulated data can be reprocessed and the new results visualised by rerunning the module diagram.

Thus picking and removing is not sufficient to define the operations we want to perform, in the current version of SciCraft. Firstly, we need a callback to the original data set, so that we can remove elements from it. Secondly, we need functionality to actually manipulate the elements in the data set according to the picked elements in the plot. All this is solved by the Edit node. The edit node contains the functionality to manipulate rows and columns in matrices. However, introducing the edit node in a module diagram only partially solves the problems. A new problem is illustrated in figure 2.55.

Figure 2.55: Data naming in the module diagram can cause confusion.
\begin{figure}\begin{center}
\includegraphics[scale=0.8]{edit.eps}\end{center}\end{figure}

We read a variable, $\mathbf{X}$ from a file and passes it through the edit node and to a function node selected by the user. The function node operates on the data to produce a matrix $\mathbf{T}$. When picking elements from the plot, we pick elements from $\mathbf{T}$. But when we want to remove the picked elements, they should be removed from $\mathbf{X}$. However, the plot node has only information and knowledge of $\mathbf{T}$. The solution to this problem is setting aliases, as explained in the next section.

Alias configuration

In this version of SciCraft, the solution to the problem above is more configuration for the user. You are required to manually tell the plot node what data the plot data is based on. In figure 2.55 we see that $\mathbf{T}$ is based on $\mathbf{X}$. We tell the plot node this by setting aliases in the plot window. The setup for aliases is located in the first tab in the plot window controller, under the button ``Set Aliases''. If you push the button the window in figure 2.56 is displayed.
Figure 2.56: The alias setup.
\begin{figure}\begin{center}
\scalebox{0.7}{\includegraphics{alias.eps}}\end{center}\end{figure}

You can see that all the input ports are listed in the leftmost box. The other boxes are empty and the two buttons in the middle are disabled. Setting aliases can only be done after you have executed a module diagram (we will come back to this in the example in section 2.6.6). Only then will the buttons be enabled, and the rightmost box will contain something. What this box contains, is dependent on the names of the data that the edit node should manipulate after picking. Hence, the ``Available aliases'' box needs to get some information from this edit node. This data is sent to the plot node on a special port named alias. This port has to be manually created and connected to the edit node's output port named ``availableAliases''. To get picking to work on the original data set, the diagram in figure 2.55 has to be modified to look like figure 2.57.

Figure 2.57: A new module diagram with aliases.
\begin{figure}\begin{center}
\includegraphics[scale=0.8]{edit2.eps}\end{center}\end{figure}

Now when we have run the module diagram, the alias setup looks something like in figure 2.58

Figure 2.58: Alias setup after the module diagram has run.
\begin{figure}\begin{center}
\scalebox{0.7}{\includegraphics{alias2.eps}}\end{center}\end{figure}

You can see that the buttons in the middle have been enabled, and we can set $\mathbf{X}$ as an alias for $\mathbf{T}$. If we now begin picking, the result will be that a series of commands will be transmitted to the edit node, telling it to manipulate its $\mathbf{X}$ data. Note that you can only set one alias for each port in the plot node in this version of SciCraft. Later versions will support several aliases for a port.


An example module diagram

The following example illustrates the use of aliases with edit and plot nodes. The module diagram used will read some data, process it through a classification method called principal component analysis (PCA) and plot the results from the PCA. What we want is to run new PCAs each time a new set of ``outlier'' objects are removed from the plot node and visualise the new results.
  1. Start up SciCraft, and begin with an empty workspace.
  2. Go into the node menu to the right and insert an ``InputNode'', ``EditNode'', ``pca'' and ``Plot'' to the workspace.
  3. Connect the file reader to the edit node.
  4. Connect the edit node to the pca node.
  5. Connect the edit node to the plot node.
  6. Connect the pca node to the plot node. Now the module diagram should be looking something like figure 2.59
    Figure 2.59: Initial setup of the example module diagram.
    \begin{figure}\begin{center}
\scalebox{0.75}{\includegraphics{exmd.eps}}\end{center}\end{figure}

  7. Start specifying the nodes and connections. Double click the file reader node and specify the filename of the data (figure 2.60.)
    Figure 2.60: Setup of the file reader.
    \begin{figure}\begin{center}
\scalebox{0.625}{\includegraphics{octnode.eps}}\end{center}\end{figure}
    Add ``M1''. Close the node setup window.

  8. Open the PCA node's nodedialog and enter the number 3 in the ``Value'' field (This will instruct the pca node to make three principal components). Close the window.
  9. Double click on the edit node and select ``Pass through'' in the drop-down box in the command tab. Add the input port ``X'' in the ``Port-Input'' tab. Close the window.
  10. Double click the plot and add the input ports ``T'' and ``alias'' in the ``Plot Setup'' tab in the window controller (figure 2.61). Close the window.
    Note! Do not set the aliases until after the module diagram has run, and before you start picking.

    Figure 2.61: Setup of ports in the plot node.
    \begin{figure}\begin{center}
\scalebox{0.625}{\includegraphics{explotsetup.eps}}\end{center}\end{figure}

  11. Start specifying connections. Double click the line between the file reader and the edit node. Connect ``M1'' and ``X''. Close the window.
  12. Double click the connection between the edit node and the pca node. Connect ``editnode_output'' with ``X'' (figure 2.62). Close the window.
    Figure 2.62: Connection setup between the edit node and the pca node.
    \begin{figure}\begin{center}
\scalebox{0.625}{\includegraphics{exconnecteditpca.eps}}\end{center}\end{figure}

  13. Double click the connection between the edit node and the plot node. Connect ``availableAliases'' and ``alias''. Close the window.
  14. Double click the connection between the pca node and the plot node. Connect the two ``T''s. Close the window.
  15. Run the module diagram by clicking the ``Run'' button.
  16. Open the plot window by double clicking on the plot node.
  17. Press the ``Add...'' button in the ``Window 1'' tab. Add a ``ScatterPlot3D'' and press ``Done''.
  18. Change the X- , Y- and Z-axis data to ``T'' if it was not set to this before. Click ``Apply setup'' and a plot should appear in the only render window (like figure 2.63).
    Note! Now we just configured the plots after the module diagram was run. In SciCraft you can choose either to add the plots before or after the module diagram has run. If you choose to add the plots before running the module diagram, and the plot does not appear afterwards, try clicking the ``Apply Setup'' button.

    Figure 2.63: Plot window after a plot has been added and its settings applied.
    \begin{figure}\begin{center}
\scalebox{0.625}{\includegraphics{exshowplot.eps}}\end{center}\end{figure}

  19. Click the ``Set Aliases...'' button in the ``Plot Setup'' tab in the window controller. Add ``X'' as an alias to ``T''. The result should be like in figure 2.64. Click ``Done''.
    Figure 2.64: Alias setup.
    \begin{figure}\begin{center}
\scalebox{0.625}{\includegraphics{exaliasrun.eps}}\end{center}\end{figure}

  20. Now, pick two elements from the plot and click the delete button in the plot window toolbar. The elements are removed from the plot, and the command instructing the edit node to remove the corresponding rows from ``X'' is sent. Close the plot window and rerun the module diagram.
    Note! If you change your mind about picking after you have removed some picked elements from the plot, you may get the elements back by clicking the undo button to the right of the delete button.

  21. Open the plot window again, and you will see the plot again, with two objects less than before picking. What did really happen? When we picked the elements and deleted them, the plot node sent a command to the edit node, instructing it to delete two rows from ``X''. When we reran the module diagram, the pca node processed ``X'' with the picked rows removed, and consequently, produced another result. This result was then displayed in the plot (figure 2.65).
    Figure 2.65: Plot after second run.
    \begin{figure}\begin{center}
\scalebox{0.625}{\includegraphics{explot2.eps}}\end{center}\end{figure}


SciCraft Development Team