2 Qanava - Graph drawing library for QT
3 Copyright (C) 2005 Benoit AUTHEMAN
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 //-----------------------------------------------------------------------------
21 // This file is a part of the Qanava software.
24 // \author Benoit Autheman (benoit@faktiss.net)
25 // \date 2004 December 05
26 //-----------------------------------------------------------------------------
33 namespace qan
{ // ::qan
34 namespace la
{ // ::qan::la
37 /* Grid Constructor and Destructor *///----------------------------------------
38 Grid::Grid( GridLayout
* layout
) :
49 //-----------------------------------------------------------------------------
53 /* Layout and Size Management *///--------------------------------------------
54 void Grid::resize( int width
, int height
)
57 _layout
->resize( width
, height
);
60 void Grid::setLayout( GridLayout
* layout
)
66 //-----------------------------------------------------------------------------
70 //-----------------------------------------------------------------------------
72 \param width Width of the grid to build (often the grid's canvas width).
73 \param height Height of the grid to build (often the grid's canvas height).
75 void GridLayoutRegular::build( int width
, int height
)
81 updateGrid( width
, height
);
85 \param width Width of the grid to build (often the grid's canvas width).
86 \param height Height of the grid to build (often the grid's canvas height).
88 void GridLayoutRegular::resize( int width
, int height
)
90 if ( _lastX
< width
&& _lastY
< height
)
91 updateGrid( width
, height
);
94 void GridLayoutRegular::updateGrid( int width
, int height
)
99 int smallGradCount
= 5;
101 if ( _lastX
+ incX
< width
) // Take care of update (do not duplicate lines)
103 _lastX
+= ( _lastX
== 0 ? 0 : incX
); // For each update, start a new line, for an initial build, start on the border
104 for ( int x
= _lastX
; x
< width
; _gridCountX
++, x
+= incX
)
109 if ( _gridCountX
% smallGradCount
== 0 )
117 getGrid( ).addVerticalLine( x
, 0, x
, height
, lineWeight
, dash
, dot
);
123 if ( _lastY
+ incY
< height
) // Take care of update (do not duplicate lines)
125 _lastY
+= ( _lastY
== 0 ? 0 : incY
); // For each update, start a new line, for an initial build, start on the border
126 for ( int y
= _lastY
; y
< height
; _gridCountY
++, y
+= incY
)
131 if ( _gridCountY
% smallGradCount
== 0 )
139 getGrid( ).addHorizontalLine( 0, y
, width
, y
, lineWeight
, dash
, dot
);
145 //-----------------------------------------------------------------------------