Home || SourceForge.net Project Page

mfGraph Library version 0.3 (June 10, 2005)

Copyright 2003-2005 Michael Fötsch

Homepage: http://www.geocities.com/foetsch/

Mail: foetsch@users.sourceforge.net

Table of Contents

Revision History

License

The mfGraph Library, pymfg, and VCL components are distributed under the terms of the Lesser General Public License. The file lgpl_license.html contains the license terms.

The mfGraph UI Sample Application is distributed under the terms of the General Public License. The file gpl_license.html contains the license terms.

Package Contents

(not all files shown)

  mfgraph-0.3/
    contrib/                 - additional files for users of Microsoft Windows
      bcb_demo/              - mfGraph UI Sample Application (Borland C++Builder)
      bcb_pymfg/             - Python extension DLL project for Borland C++Builder
      mfc_demo/              - MFC-based demo application
      pymfg_demo/            - wxPython demo application
      windows_lib/           - mfGraph library project files for Visual C++ 6.0
      windows_pymfg/         - Python extension DLL project for Visual C++ 6.0
      mfc_demo.exe           - precompiled MFC demo for Windows
      mfgraphui.exe          - precompiled mfGraphUI Sample App for Windows
    doc/
      html/
        index.html           - source code documentation
    pymfg/                   - Python extension library sources
    src/                     - mfGraph library sources
    test/                    - simple C++ test application
    INSTALL                  - generic installation instructions for Automake-based build    

Optional and Required Third-Party Packages

You might need the following additional packages:

These are the software versions that I tested with:

Software

Version

Bison

1.875

Doxygen

1.4.1

Flex

2.5.4

GCC

3.3.5

dot (GraphViz package)

2.2

Python

2.4 (GNU/Linux) / 2.3 (Windows)

Swig

1.3.21

wxPython

2.5.3.1 (GNU/Linux) / 2.4.1.2 (Windows)

Build Instructions GNU/Linux

In the mfgraph-0.3 directory, run these shell commands:

mkdir build
cd build
../configure
make
make install

As usual, run ../configure --help for help on additional settings.

The following items will be installed:

Build Instructions Windows

You need the following software to be able to rebuild the library and sample applications:

Microsoft Visual C++-Specific

  1. Optionally, add the paths to flex.exe, bison.exe, and swig.exe in "Tools" -> "Options" -> "Directories"

  2. Optionally, add the path to Python.h (typically C:\Python2x\include) in "Tools" -> "Options" -> "Directories"

  3. Optionally, add the path to python2x.lib (typically C:\Python2x\libs) in "Tools" -> "Options" -> "Directories"

  4. Open the workspace contrib\mfc_demo\mfc_demo.dsw and build the project "mfc_demo". This will also build the mfGraph DLL in contrib\windows_lib.

    • Note: "Rebuild All" requires Flex/Bison to be installed, unless you check "Exclude from Build" in the options of the files mfg_flex.ll and mfg_bison.yy.

  5. To build the Python extension DLL, open the workspace contrib\windows_pymfg and build the project

    • Note: "Rebuild All" requires Swig to be installed, unless you check "Exclude from Build" in the options of the file swig.i.

  6. To install the Python extension DLL, run "setup.py install"

Issues:

Borland C++Builder-Specific

Before you can build or run the mfGraph UI Sample Application, you must

To build the mfGraphUI Sample Application:

  1. Open the project group contrib\bcb_demo\ProjectGroup1.bpg

  2. Build the project "mfgraph_lib"
  3. Build and install the package "mf"; new VCL components will be registered
  4. Build the project "mfgraphui"

To build the Python extension DLL:

  1. Convert the Python import library python23.lib (typically in C:\Python23\libs) to OMF format, e.g.:
    • > cd C:\Python23\libs
      > C:\Program Files\Borland\CBuilder5\bin\coff2omf.exe python23.lib python23_omf.lib
  2. Open the project group contrib\bcb_pymfg\ProjectGroup1.bpg

  3. If Python is not installed in C:\Python23 (for example, because you are using a different version), you will have to modify the paths in the Project Options accordingly
  4. If python23_omf.lib is not in C:\Python23\libs, remove python23_omf.lib from the project and re-add it from its actual location
  5. Build the project "_pymfg"
  6. To install the Python extension DLL, run "setup.py install"

Issues:

mfGraph Library Usage Example

(Those parts that make use of class mfg::GraphDrawer are specific to Microsoft Windows.)

This is a simple usage example to demonstrate

We would like to render the following graph:

    digraph G {
        a -> x [color=red]
        subgraph {
            b [style=filled fillcolor=green]
        }
        a -> b
    }

Step 1. Create a new application and either add mfgraph_lib.lib or add all CPP files in the mfGraph root directory.

Step 2. Create the graph using the mfg::DrawGraph class as follows:

   1     #include "mfg_draw_graph.h"
   2     #include "mfg_graph_drawer.h"
   3     using namespace mfg;
   4     ...
   5     DrawGraph g;
   6     Node* a = g.CreateNode();
   7     Node* x = g.CreateNode();
   8     Edge* ax = g.CreateEdge(a, x);
   9     ax->Attribs()["color"] = "red";
  10     Subgraph* s = g.CreateSubgraph();
  11     Node* b = g.CreateNode(s);
  12     b->Attribs()["style"] = "filled";
  13     b->Attribs()["fillcolor"] = "green";
  14     Edge* ab = g.CreateEdge(&g, &a, &b);

Step 3. Write the graph to a DOT file on disk. (We could have written the DOT listing to a file directly, but it's more interesting this way.)

   1     #include <iostream>
   2     ...
   3     std::ofstream dot("temp.dot");
   4     g.PrintAsDot(dot);

Step 4. Have DOT.EXE convert the DOT listing to XDOT format. (This is the format that contains information about the graphic primitives such as ellipses and Bézier curves.)

   1     system("dot.exe -Txdot -otemp.xdot temp.dot");
   2         // requires the GraphViz package

Step 5. Windows only. Load the XDOT graph from the newly created file and have mfg::GraphDrawer render the graph:

   1     HDC hdc;    // assumed to contain a valid device context
   2     ...
   3     std::ifstream xdot("temp.xdot");
   4     g.LoadFromXdot(xdot);
   5     GraphDrawer::DrawGraph(hdc, &g);

Run the application.

mfGraph UI Sample Application Usage

Before you can use the mfGraph UI Sample Application, you must

In addition to those attributes defined by DOT.EXE, mfGraph UI supports the following special node, edge, and graph attributes (mfc_demo and pymfg_demo support these as well):

Attribute

Description

Values

_mfg_fillstyle

Fill style that is used when attribute style="filled"

FILL_STYLE_SOLID
FILL_STYLE_CLEAR
FILL_STYLE_DIAG
FILL_STYLE_BACK_DIAG
FILL_STYLE_CROSS
FILL_STYLE_DIAG_CROSS
FILL_STYLE_HORZ
FILL_STYLE_VERT

_mfg_fontfamily

Font family for node and edge labels

FONT_FAMILY_DECORATIVE
FONT_FAMILY_MODERN
FONT_FAMILY_ROMAN
FONT_FAMILY_SCRIPT
FONT_FAMILY_SWISS

_mfg_fontstyle

Font style for node and edge labels

FONT_STYLE_REGULAR
FONT_STYLE_BOLD
FONT_STYLE_ITALIC
FONT_STYLE_BOLD_ITALIC

_mfg_labelfontfamily

Font family for head and tail labels

Same as _mfg_fontfamily

_mfg_labelfontstyle

Font style for head and tail labels

Same as _mfg_fontstyle

_mfg_penstyle

Line style for node and subgraph borders and for edges

PEN_STYLE_SOLID
PEN_STYLE_DASH
PEN_STYLE_DOT
PEN_STYLE_DASH_DOT
PEN_STYLE_DASH_DOT_DOT
PEN_STYLE_NULL

_mfg_penwidth

Line width for node and subgraph borders and for edges.
Please note that _mfg_penstyle other than PEN_STYLE_SOLID will not work for line widths greater than 1.

Line width in pixels

ReleaseNotes0.3 (last edited 2008-10-31 15:44:14 by localhost)


Copyright © 2003-2009 [WWW] Michael Fötsch. Visit [WWW] RealMike's Programming Resources.