1 //-----------------------------------------------------------------------------
2 // This file is a part of the Qanava software.
4 // \file canMainWindow.cpp
5 // \author Benoit Autheman (benoit@libqanava.org)
6 // \date 2005 November 11
7 //-----------------------------------------------------------------------------
11 #include "../../src/qanGraphView.h"
12 #include "../../src/qanGrid.h"
13 #include "./canMainWindow.h"
19 #include <QHeaderView>
20 #include <QTextCursor>
27 //-----------------------------------------------------------------------------
28 MainWindow::MainWindow( QWidget
* parent
) :
33 QHBoxLayout
*hbox
= new QHBoxLayout( _frame
);
36 // Generate a simple graph
37 Graph
* graph
= new Graph( );
39 Node
& nq
= *graph
->addNode( "<b> Q</b>" );
40 Node
& na1
= *graph
->addNode( "<b>a</b>" );
41 graph
->addEdge( nq
, na1
, 4.f
);
43 Node
& nn
= *graph
->addNode( "<b>n</b>" );
44 graph
->addEdge( na1
, nn
, 3.f
);
46 Node
& na2
= *graph
->addNode( "<b>a</b>" );
47 graph
->addEdge( nn
, na2
, 2.f
);
49 Node
& nv
= *graph
->addNode( "<b>v</b>" );
50 graph
->addEdge( na2
, nv
);
52 Node
& na3
= *graph
->addNode( "a" );
53 graph
->addEdge( nv
, na3
);
56 qan::GraphView
* graphView
= new qan::GraphView( _frame
);
57 GridItem
* grid
= new GridCheckBoardItem( graphView
, palette( ).color( QPalette::Base
), palette( ).color( QPalette::AlternateBase
) );
58 hbox
->addWidget( graphView
);
60 Style
* greenNode
= new Style( "greennode" );
61 greenNode
->addImageName( "backimage", "images/gradgreen.png" );
62 greenNode
->addColor( "bordercolor", 50, 100, 200 );
63 greenNode
->addT
< int >( "fontsize", 18 );
64 greenNode
->addT
< int >( "maximumwidth", 25 );
65 graphView
->applyStyle( &nq
, greenNode
);
67 Style
* iconNode
= new Style( "iconnode" );
68 iconNode
->addImageName( "backimage", "images/gradblue.png" );
69 iconNode
->addColor( "bordercolor", 0, 255, 0 );
70 iconNode
->addT
< int >( "maximumwidth", 20 );
71 iconNode
->addT
< int >( "fontsize", 16 );
72 graphView
->applyStyle( &na1
, iconNode
);
74 Style
* orangeNode
= new Style( "orangenode" );
75 orangeNode
->addImageName( "backimage", "images/gradorange.png" );
76 orangeNode
->addColor( "bordercolor", 50, 100, 200 );
77 orangeNode
->addT
< int >( "fontsize", 14 );
78 orangeNode
->addT
< int >( "maximumwidth", 15 );
79 orangeNode
->addT
< int >( "maximumheight", 25 );
80 graphView
->applyStyle( &nn
, orangeNode
);
81 graphView
->applyStyle( &na2
, orangeNode
);
82 graphView
->applyStyle( &nv
, orangeNode
);
84 Style
* redNode
= new Style( "rednode" );
85 redNode
->addImageName( "backimage", "images/gradred.png" );
86 redNode
->addColor( "bordercolor", 50, 100, 200 );
87 redNode
->addT
< int >( "fontsize", 14 );
88 redNode
->addT
< int >( "maximumwidth", 14 );
89 graphView
->applyStyle( &na3
, redNode
);
91 graphView
->setGraph( *graph
);
92 graphView
->layoutGraph( );
94 //-----------------------------------------------------------------------------