The Rocs Handbook

The Rocs Handbook

Tomaz Canabrava

Revision 1.0 (2009-11-05)

Rocs is a graph theory viewer tool for KDE.


Chapter 1. Introduction

Chapter 1. Introduction

Rocs aims to be a Graph Theory IDE for helping professors to show the results of a graph algorithm and also helping students to do the algorithms.

Rocs has a scripting module, done in Qt Script, that interacts with the drawn graph and every change in the graph with the script is reflected on the drawn one.

Chapter 2. Using Rocs

Chapter 2. Using Rocs

The user interface is divided in two parts:

  • the top right part is where you draw your graphs, and the bottom right one is where you create your algorithms,

  • the left sidebar is where all your open graphs stay, you can open multiple graphs per file.

Rocs global settings

On the left sidebar you can find the options for each opened graph, all these options are global per graph and can be changed per node and edge with the Node Properties and the Edge Properties dialogs.

  • Graph Name

  • Node Color for new created nodes, you can change the node color for all current nodes by clicking the All button

  • Edge Color

The last row of options consists in toggled buttons:

  • Oriented Graph

  • Automated Graph

  • Show nodes names

  • Show edges names

  • Show nodes values

  • Show edges values

Rocs toolbars

Rocs toolbars

There are two toolbars, on the top. The main one has the following tools:

  • Move Node: moves a node around the drawing area.

  • Add Node: creates a new node at the clicked position on the drawing area.

  • Add Edge: creates a new edge between two nodes.

  • Select: select items by clicking on them.

  • Delete: delete items by clicking on them.

A right mouse click on a node or edge brings you the property dialog for that node or edge.

The layout toolbar consists in various aligns icons.

To align nodes, choose the Select tool, click and drag a rectangle, then choose the alignement that you want.

Chapter 3. Scripting Rocs

Chapter 3. Scripting Rocs

After the graph is on screen, you can start creating the script for it. The language uses a Javascript syntax and following are the Graph, Node and Edge objects.

Graph

     array list_nodes();
     array list_edges();
     node add_node(name);
     edge add_edge(from, to);
     node node_byname(QString& name);
     node begin_node();
     array end_nodes();

Graph variables that can be changed:

     bool directed
     bool automate
     string name
     string nodeDefaultColor // in HEXA
     string edgeDefaultColor  // in HEXA 
Nodes

Nodes

     array adj_nodes();
     array adj_edges();
     array  input_edges();
     array output_edges();
     array loop_edges();
     array connected_edges(Node *n);
     void self_remove();

Node Variables:

    double x
    double y
    double width
    string value
    string name
    string color  // in HEXA
    bool begin
    bool end
Edges

Edges

    string color ( em hexa )
    string value
    string name
    double width
    string style ( dot, dash, dash dot, solid )

    node start();
    node  end();

    void self_remove();
Example

Example

Here is a simple script example that sets the color of the 4 first nodes in the first graph:

/* A simple example that sets the color of the 4 first nodes in the first 
graph: */
 
var colours = new Array("red", "green", "blue", "yellow");

/* graphs is an array of graphs, you can access a graph by its index in the 
array or by its name, so if the first graph's name is Untitled0, the following 
sentence are right  */
var list1= graphs[0].list_nodes(); //  1st form.
var list2=Untitled0.list_nodes();              // 2nd form
 
 for ( var i = 0; i < colours.length; i++){
        if (i > list2.length) break;
        list2[i].color = colours[i]
 }
Chapter 4. Command Reference

Chapter 4. Command Reference

Menus and Shortcut Keys

The File Menu

File->Quit (Ctrl+Q)

Quits Rocs

The Settings Menu

Settings->Toolbars Shown

Toggle the Main, and Layout toolbars.

Settings->Show Statusbar

Toggle the statusbar.

Settings->Configure Shortcuts...

Open standard KDE setting dialog that allows you to choose different shortcut keys for different actions.

Settings->Configure Toolbars...

Configure the items you want to put in the toolbar.

The Help Menu

Help->Rocs Handbook (F1)

Invokes the KDE Help system starting at the Rocs help pages. (this document).

Help->What's This? (Shift+F1)

Changes the mouse cursor to a combination arrow and question mark. Clicking on items within Rocs will open a help window (if one exists for the particular item) explaining the item's function.

Help->Report Bug...

Opens the Bug report dialog where you can report a bug or request a “wishlist” feature.

Help->Switch Application Language...

Opens a dialog where you can edit the Primary language and Fallback language for this application.

Help->About Rocs

This will display version and author information.

Help->About KDE

This displays the KDE version and other basic information.

Chapter 5. Credits and License

Chapter 5. Credits and License

Rocs

Program copyright 2009 Tomaz Canabrava tcanabrava at kde dot org

Documentation copyright 2009 Anne-Marie Mahfouf and Tomaz Canabrava tcanabrava at kde dot org

This documentation is licensed under the terms of the GNU Free Documentation License.

This program is licensed under the terms of the GNU General Public License.

Appendix A. Installation

Appendix A. Installation

How to obtain Rocs

Rocs is part of the KDE project http://www.kde.org/.

Rocs can be found in the kdeedu package on ftp://ftp.kde.org/pub/kde/, the main FTP site of the KDE project.

Compilation and installation

Compilation and installation

For detailed information on how to compile and install KDE applications see Building KDE4 From Source

Since KDE uses cmake you should have no trouble compiling it. Should you run into problems please report them to the KDE mailing lists.