summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* QGraphicsAnchorLayout: Remove center anchors when not neededEduardo M. Fleury2009-07-223-3/+71
| | | | | | | | | Continuing the effort to enforcing center anchors to exist only when needed, this commit removes the central anchors when they are no longer used. Signed-off-by: Eduardo M. Fleury <eduardo.fleury@openbossa.org> Reviewed-by: Anselmo Lacerda S. de Melo <anselmo.melo@openbossa.org>
* QGraphicsAnchorLayout: Create center edges on demandEduardo M. Fleury2009-07-222-0/+63
| | | | | | | | | | Since the previous commit, center anchors are no longer created when an item is added to the layout. This commit creates only the required anchors, when needed. Signed-off-by: Eduardo M. Fleury <eduardo.fleury@openbossa.org> Reviewed-by: Anselmo Lacerda S. de Melo <anselmo.melo@openbossa.org>
* QGraphicsAnchorLayout: Do not create center anchors by defaultEduardo M. Fleury2009-07-221-28/+8
| | | | | | | | | | | | | | | | | Previously we would create two half anchors internally to each item added to the layout. These anchors are meant to enforce the central anchorage point remains on its position. It is not effecient however, to create these anchors for all items if not all of them will have anchors linked to their center. This commit removes the creation of center anchors, the idea is to postpone this to the moment their are really needed, therefore reducing the number of variables and constraints sent to the simplex solver on the average case. Signed-off-by: Eduardo M. Fleury <eduardo.fleury@openbossa.org> Reviewed-by: Anselmo Lacerda S. de Melo <anselmo.melo@openbossa.org>
* QGraphicsAnchorLayout: Testing for existing anchors before adding new onesEduardo M. Fleury2009-07-221-0/+5
| | | | | | | | | | The layout was not aware of the fact an anchor could already exist when it was added. This commit ensures that only one anchor exists between two vertices to avoid unwanted behavior and memory leaks (AnchorData's and Vertices would leak otherwise). Signed-off-by: Eduardo M. Fleury <eduardo.fleury@openbossa.org> Reviewed-by: Anselmo Lacerda S. de Melo <anselmo.melo@openbossa.org>
* QGraphicsAnchorLayout: Initialize spacing variablesEduardo M. Fleury2009-07-221-0/+2
| | | | | | | To avoid non-deterministic behavior. Signed-off-by: Eduardo M. Fleury <eduardo.fleury@openbossa.org> Reviewed-by: Anselmo Lacerda S. de Melo <anselmo.melo@openbossa.org>
* QGraphicsAnchorLayout: Use Q_ASSERT instead of "if" testsEduardo M. Fleury2009-07-222-10/+10
| | | | | | | | Replacing two IF tests for Q_ASSERT statements instead. These tests are sanity checks that should never be false. Signed-off-by: Eduardo M. Fleury <eduardo.fleury@openbossa.org> Reviewed-by: Anselmo Lacerda S. de Melo <anselmo.melo@openbossa.org>
* Anchors to center edges should also have a default spacing of 0.Jan-Arve Sæther2009-07-221-6/+16
| | | | | Since the spacing will be 0 in most cases, we therefore "invert" the if (..) to only check for the cases where the spacing will *not* be zero.
* Make sure that internal center anchors are not simplified.Jan-Arve Sæther2009-07-222-2/+76
|
* Can now specify which layout to load on the command line.Jan-Arve Sæther2009-07-223-4/+10
|
* Explicitly use a spacing of 0 in order to keep old behaviour.Jan-Arve Sæther2009-07-221-23/+23
| | | | | This broke after commit 0872f78d8924b9bea8b8da6618e24cd7d06c5d7d that fixed the default spacings.
* Fix typo: feaseable => feasibleJan-Arve Sæther2009-07-221-1/+1
|
* The simplification makes the parallel autotest fail. Disable it for now.Jan-Arve Sæther2009-07-221-4/+4
|
* Avoid some warnings (unused variables)Jan-Arve Sæther2009-07-221-2/+0
|
* Add QGraphicsLayout::anchor() overloads and query the default spacing.Jan-Arve Sæther2009-07-225-104/+316
| | | | | | | | | | | | | | | | | | | | | | | | | | This commit fixes several related issues: 1. QGAL::anchor() had a spacing argument that defaulted to 0. That made it impossible to know if the user meant that the spacing should be 0 or if the spacing should be picked from the style. Instead we have to overload anchor, so now we have one function that does not take spacing as an argument. That one will create an anchor where the spacing is queried from the style. The other overload allows the user to explicitly set the spacing, thus the default spacing is ignored. 2. Make sure we pick up the spacing correctly from the style if needed. setAnchorSizeHintsFromDefaults() will set the correct spacing on anchors that was created without specifying a spacing value. 3. Add QGAL::anchor(Qt::Corner, ...) convenience function with an overload (for the same reason as explained in 1.) 4. Added QGraphicsAnchorLayoutPrivate::anchor() as a helper function that is called from all the 4 public API anchor() functions so that we don't need to have duplicate code for argument checking etc. 5. Fix autotests. They assumed that anchor() without a spacing argument created a spacing of 0.
* QSimplex: Skip x = x + y*0.0Anselmo Lacerda S. de Melo2009-07-221-1/+7
| | | | | | | | A small optimization. Added a verification in combineRows to skip calculating x = x + y*0.0 as it obviously won't change the value of x. Signed-off-by: Anselmo Lacerda S. de Melo <anselmo.melo@openbossa.org>
* QSimplex: new method solver, avoinding code replicationAnselmo Lacerda S. de Melo2009-07-222-18/+18
| | | | | | | | | | | The methods solveMin() and solveMax() had similar implementation, except by a "-1" multiplier. This commit includes a new private method called solver that is called by both solveMin() and solveMax(). A new enum 'solverFactor' was added admiting 2 values - Maximum (+1) and Minimum (-1). Signed-off-by: Anselmo Lacerda S. de Melo <anselmo.melo@openbossa.org>
* Use whitespaces and newlines when saving the xml file.Jan-Arve Sæther2009-07-221-15/+16
| | | | Some whitespace cleanup.
* Implemented parallel simplification, some bugfixes of the previous code.Jan-Arve Sæther2009-07-223-44/+104
| | | | | | | | | | Currently, the code is not in effect for the simplex solver kicks in (it crashes), but it is in effect for each layout to check that simplification and restoring the simplification back again works. This is currently done in calculateGraphs() Parts of the code does not read well, especially the detection of the sequential chunks.
* QGraphicsAnchorLayout: Add convencience "fill" methodsEduardo M. Fleury2009-07-221-0/+36
| | | | | | | | | | | | | | | Adding "fillWidth()", "fillHeight()" and "fill()". These convenience methods simplify the creation of anchor setups where some items are meant to use the full width and/or height of the layout. For instance, instead of creating four anchors (bottom, top, left, right) between an item and the layout, to make it use the full layout area, the user can call layout->fill(item). It is also possible to make an item assume the same width or height of another item, calling layout->fill(firstItem, secondItem). Signed-off-by: Eduardo M. Fleury <eduardo.fleury@openbossa.org>
* QGraphicsAnchorLayout: Fix QGraphicsItem reparent codeEduardo M. Fleury2009-07-224-38/+3
| | | | | | | Using QGraphicsLayoutPrivate methods for proper reparenting of items. This makes it work in cases where nested layouts are used. Signed-off-by: Eduardo M. Fleury <eduardo.fleury@openbossa.org>
* Simplify the code that finds the sequential chunks for simplification.Jan-Arve Sæther2009-07-221-14/+4
| | | | | | If two vertices are adjacent in the candidate list they should also be adjacent in the graph. This means there should always be an edge between candidates.at(n) and candidates.at(n + 1).
* Improved sequential simplification. Added restoreSimplifiedGraph().Jan-Arve Sæther2009-07-222-56/+197
| | | | | | | See comment in simplifyGraph on how the overall approach is. There are still outstanding issues: 1. Simplify parallel anchors 2. Use linear layout to distribute sequential anchors.
* Improve how graphviz (dotty) renders the serialized graph.Jan-Arve Sæther2009-07-221-1/+10
| | | | | The black arrow shows the principal direction based on the "origin" member of AnchorData.
* Simplify the graph by replacing a sequence of anchors with one anchor.Jan-Arve Sæther2009-07-222-2/+172
| | | | | | | We insert a special SequentialAnchorData. This anchor's min/pref/maxSize will be the sum of the sizes of all the anchors it is replacing. This should make the equation solver faster, and will enable us to do distribution properly just like a linear layout would do.
* Added the possibility to save a layout.Jan-Arve Sæther2009-07-223-34/+85
| | | | Keep it simple...
* Some cleanup - improve dot dumper.Jan-Arve Sæther2009-07-223-70/+52
| | | | | | | | | | | | | | | | | The previous dumper relied on traversal of the graph, which meant that it would not output the nodes that were not connected to the "main" graph. Due to this, we cannot rely on traversal, so instead we must iterate through all the vertices of the graph. As an added bonus the code gets simpler :-) There was also a problem with the previous dumper, since it dumped two "digraph" elements into one file. Graphwiz (win32) did not handle that. Instead just dump all the nodes and all the connections, both horizontal and vertical ones. The horizontal and vertical connections are never connected anyway, so the result will be two separate graphs when it is rendered by graphwiz. Also renamed firstVertex to rootVertex and simplified it.
* Add an exampleJan-Arve Sæther2009-07-2213-0/+1645
| | | | Should hopefully be easier to test layouts now...
* QGraphicsAnchorLayout: Fix memory management issue in QSimplex solverEduardo M. Fleury2009-07-223-50/+54
| | | | | | | | | | | | | | | Both QGraphicsAnchorLayoutPrivate::solveMinMax() and solvePreferred() were deleting the linear programming contraints while QSimplex still had them. For solveMinMax(), move the creation of constraints out of that method. For solvePreferred(), create the simplex solver in the heap so it can be deleted before the constraints are. Signed-off-by: Eduardo M. Fleury <eduardo.fleury@openbossa.org> Reviewed-by: Anselmo Lacerda S. de Melo <anselmo.melo@openbossa.org>
* QGraphicsAnchorLayout: Delete center constraints on item removalEduardo M. Fleury2009-07-223-11/+41
| | | | | | | | | | Each time an item is added to the layout, center constraits are created to ensure its internal anchors keep their size equal. To avoid memory leaks, we must delete them when the item is removed. Signed-off-by: Eduardo M. Fleury <eduardo.fleury@openbossa.org>
* QGraphicsAnchorLayout: Removing delete d_ptrAnselmo Lacerda S. de Melo2009-07-221-3/+0
| | | | | | Removed an obsolete delete d_ptr, since it is not needed anymore. Signed-off-by: Anselmo Lacerda S. de Melo <anselmo.melo@openbossa.org>
* QGraphicsAnchorLayout: Update m_vertexList reference count systemEduardo M. Fleury2009-07-222-26/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The reference count system used to delete AnchorVertex objects stored in m_vertexList had an issue that prevented the count values from being stored properly. This is a tentative fix for the memory leaks in the layout, changes were made to the m_vertexList access methods as well as those that use them. 1) addInternalVertex() After incrementing the ref count, store it in m_vertexList. 2) removeInternalVertex() To make it symmetrical to addInternalVertex() we delete the anchor vertex if its reach count reaches zero. From now on, the only methods that create or delete vertices are these two. All other methods should rely on add/removeInternalVertex. Also made the method 'void'. This method is called to release the associated object and may trigger a deletion of it, thus any use of the object reference after that is unsafe. Other methods can get a reference with internalVertex(). 3) removeAnchor() Follow above instructions. No longer relies on the reference returned by removeInternalVertex(), instead, use the reference first then release. Note: In this particular case, we know that "removeEdge(v1, v2)" will only access the contents of the pointers, not the referenced object. Yet, the change probably pays itself for the sake of clarity and safety. 4) removeAnchors() Each tiime an anchor is created, the reference count of its both vertices is incremented, thus we should decrement that count every time we remove an anchor. (Instead of removing v1 only once). Also, leave the task of deleting v1 to removeInternalVertex() as explained above. Removing the constraints handling code. I understand that we cannot leave constraints with dangling pointers inside of them, however that raises an even worse problem. Every time an item is added, we create an item center constraint, thus we must be sure to delete those when the item is removed. Once we do that, we won't have bad constraints laying around. This issue remains open in this commit but will be solved soon. Signed-off-by: Eduardo M. Fleury <eduardo.fleury@openbossa.org>
* QGraphicsAnchorLayout: Bugfix in spacing() methodEduardo M. Fleury2009-07-221-1/+2
| | | | | | | | In the public Qt::Orientation enum, Horizontal and Vertical mean 0x1 and 0x2 respectivelly, this was causing the internal data structure to be accessed in positions 0 and 2 instead of 0 and 1. Signed-off-by: Eduardo M. Fleury <eduardo.fleury@openbossa.org>
* QGraphicsAnchorLayout: Apply Jan-Arve's patchEduardo M. Fleury2009-07-225-80/+136
| | | | | | Applying the patch sent by email. Signed-off-by: Eduardo M. Fleury <eduardo.fleury@openbossa.org>
* QGraphicsAnchorLayout: Temporary destructor to avoid memory leaksEduardo M. Fleury2009-07-221-0/+12
| | | | | | | | | | | | Currently the itemCenterConstraints that are created when an item is added to the layout are never being deleted. Ideally this should be done by the time the item is removed from the layout, this requires some changes in the data structures used though. As a temporary solution we keep all of them until the layout is destroyed. Signed-off-by: Eduardo M. Fleury <eduardo.fleury@openbossa.org>
* QGraphicsAnchorLayout: Delete internal layout edges in destructorEduardo M. Fleury2009-07-223-0/+13
| | | | | | | The internal layout anchors were leaking, now we delete them when destroying the layout. Signed-off-by: Eduardo M. Fleury <eduardo.fleury@openbossa.org>
* QGraphicsAnchorLayoutExample: Delete objects to avoid memory leaksEduardo M. Fleury2009-07-221-1/+6
| | | | Delete objects from heap.
* QGraphicsAnchorLayout: Bugfix in preferred size calculationEduardo M. Fleury2009-07-221-3/+7
| | | | | | | | Observe the "skipInPreferred" flag in AnchorEdges to avoid adding the layout internal anchors to the preferred size calculation, what was leading to non-optimal results. Signed-off-by: Eduardo M. Fleury <eduardo.fleury@openbossa.org>
* QGraphicsAnchorLayout: Bugfix, set skipInPreferred flag for verticalEduardo M. Fleury2009-07-221-0/+2
| | | | | | | | | | We don't want the layout internal anchors to be used in the preferred size calculation, therefore we must set this flag. It was already being set for horizontal edges but for the vertical ones this was missing. Signed-off-by: Eduardo M. Fleury <eduardo.fleury@openbossa.org>
* QGraphicsAnchorLayout: Adding an usage exampleJesus Sanchez-Palencia2009-07-224-1/+243
| | | | Signed-off-by: Jesus Sanchez-Palencia <jesus.palencia@openbossa.org>
* QGraphicsAnchorLayout: Making private class inherit from QGraphicsLayoutPrivateJesus Sanchez-Palencia2009-07-223-8/+5
| | | | Signed-off-by: Jesus Sanchez-Palencia <jesus.palencia@openbossa.org>
* QGraphicsAnchorLayout: Adding auto-testsJesus Sanchez-Palencia2009-07-223-0/+356
| | | | | | | Signed-off-by: Anselmo Lacerda S. de Melo <anselmo.melo@openbossa.org> Signed-off-by: Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org> Signed-off-by: Eduardo M. Fleury <eduardo.fleury@openbossa.org> Signed-off-by: Jesus Sanchez-Palencia <jesus.palencia@openbossa.org>
* QGraphicsAnchorLayout: Adding QGraphicsAnchorLayout public and private classesJesus Sanchez-Palencia2009-07-225-2/+1707
| | | | | | | | | | | | | This is a total re-written implementation of QGraphicsAnchorLayout using a numerical approach. We use QGraph and QSimplex in order to achieve this. This first commit gives us a just ready-to-use qgraphicslayout, but the private class still need to inherit from qgraphicslayoutprivate. Optimizations and documentation are all work in progress. Signed-off-by: Anselmo Lacerda S. de Melo <anselmo.melo@openbossa.org> Signed-off-by: Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org> Signed-off-by: Eduardo M. Fleury <eduardo.fleury@openbossa.org> Signed-off-by: Jesus Sanchez-Palencia <jesus.palencia@openbossa.org>
* QSimplex: Adding the Simplex solver for linear systemsJesus Sanchez-Palencia2009-07-223-2/+488
| | | | | | | | | | | | | This implementation is based on the iterative algorithm presented in http://en.wikibooks.org/wiki/Operations_Research/The_Simplex_Method. It is capable of giving us the solution to any n variable LP model. Although we focused on QGraphicsAnchorLayout, the solver is general enough for being reused in any other Qt classes if needed. Signed-off-by: Anselmo Lacerda S. de Melo <anselmo.melo@openbossa.org> Signed-off-by: Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org> Signed-off-by: Eduardo M. Fleury <eduardo.fleury@openbossa.org> Signed-off-by: Jesus Sanchez-Palencia <jesus.palencia@openbossa.org>
* QGraph: Adding the graph structureJesus Sanchez-Palencia2009-07-222-1/+181
| | | | | | | | | | This file was originally included by Alexis Menard <alexis.menard@nokia.com> but now it has been fully updated to the new QGraphicsAnchorLayout needs. Signed-off-by: Anselmo Lacerda S. de Melo <anselmo.melo@openbossa.org> Signed-off-by: Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org> Signed-off-by: Eduardo M. Fleury <eduardo.fleury@openbossa.org> Signed-off-by: Jesus Sanchez-Palencia <jesus.palencia@openbossa.org>
* Fixed compile with -qtnamespace and MSVC.Rohan McGovern2009-07-222-5/+8
| | | | | When an extern function is declared in the scope of another function, MSVC sometimes ignores the enclosing namespace {}.
* Fixed valgrind warnings related to sigaction from every testcase.Rohan McGovern2009-07-211-1/+1
| | | | Whoops, don't do sigaction for (nonexistent) signal 0.
* Doc: documentation for boolean properties should say what happens whenVolker Hilsheimer2009-07-211-5/+7
| | | | the property is set, not what doesn't happen when the property is not set.
* Doc: make potentially incorrect overloads obsolete.Volker Hilsheimer2009-07-212-3/+25
| | | | | | Also add additional overload. Reviewed-by: Andreas
* Silence compiler warnings on shadowing of member functions.Volker Hilsheimer2009-07-211-11/+11
|
* Doc: document reimplementations of internal functions as internal.Volker Hilsheimer2009-07-214-8/+8
|