Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
OpenWalnut Core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
44
Issues
44
List
Boards
Labels
Service Desk
Milestones
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
OpenWalnut
OpenWalnut Core
Commits
4580209e
Commit
4580209e
authored
Apr 08, 2011
by
Sebastian Eichelbaum
Browse files
Options
Browse Files
Download
Plain Diff
[MERGE]
parents
06b44e86
7370d3f2
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
792 additions
and
57 deletions
+792
-57
src/gui/qt4/CMakeLists.txt
src/gui/qt4/CMakeLists.txt
+5
-3
src/gui/qt4/networkEditor/WQtNetworkArrow.cpp
src/gui/qt4/networkEditor/WQtNetworkArrow.cpp
+1
-0
src/gui/qt4/networkEditor/WQtNetworkArrow.h
src/gui/qt4/networkEditor/WQtNetworkArrow.h
+1
-0
src/gui/qt4/networkEditor/WQtNetworkEditor.cpp
src/gui/qt4/networkEditor/WQtNetworkEditor.cpp
+52
-42
src/gui/qt4/networkEditor/WQtNetworkEditor.h
src/gui/qt4/networkEditor/WQtNetworkEditor.h
+8
-4
src/gui/qt4/networkEditor/WQtNetworkItem.cpp
src/gui/qt4/networkEditor/WQtNetworkItem.cpp
+6
-0
src/gui/qt4/networkEditor/WQtNetworkItem.h
src/gui/qt4/networkEditor/WQtNetworkItem.h
+12
-2
src/gui/qt4/networkEditor/layout/WNetworkLayout.cpp
src/gui/qt4/networkEditor/layout/WNetworkLayout.cpp
+117
-0
src/gui/qt4/networkEditor/layout/WNetworkLayout.h
src/gui/qt4/networkEditor/layout/WNetworkLayout.h
+83
-0
src/gui/qt4/networkEditor/layout/WNetworkLayoutGlobals.h
src/gui/qt4/networkEditor/layout/WNetworkLayoutGlobals.h
+33
-0
src/gui/qt4/networkEditor/layout/WNetworkLayoutItem.cpp
src/gui/qt4/networkEditor/layout/WNetworkLayoutItem.cpp
+211
-0
src/gui/qt4/networkEditor/layout/WNetworkLayoutItem.h
src/gui/qt4/networkEditor/layout/WNetworkLayoutItem.h
+155
-0
src/modules/eigenSystem/WMEigenSystem.cpp
src/modules/eigenSystem/WMEigenSystem.cpp
+72
-4
src/modules/eigenSystem/WMEigenSystem.h
src/modules/eigenSystem/WMEigenSystem.h
+36
-2
No files found.
src/gui/qt4/CMakeLists.txt
View file @
4580209e
...
...
@@ -7,7 +7,7 @@ INCLUDE_DIRECTORIES( ${QT_INCLUDE_DIR} )
# Libraries for linking:
SET
(
QT_LIBS
${
QT_QTCORE_LIBRARY
}
${
QT_QTGUI_LIBRARY
}
${
QT_QTOPENGL_LIBRARY
}
${
QT_QTOPENGL_LIBRARY
}
${
QT_QTWEBKIT_LIBRARY
}
)
# add here all classes that inherit from QObject
...
...
@@ -55,8 +55,10 @@ ENDIF()
QT4_WRAP_CPP
(
GUI_QT4_MOC_SRCS
${
GUI_QT4_MOC_HDRS
}
)
FILE
(
GLOB GUI_QT4_SRC
"*.cpp"
"guiElements/*.cpp"
"controlPanel/*.cpp"
"events/*.cpp"
"networkEditor/*.cpp"
"*.h"
"guiElements/*.h"
"controlPanel/*.h"
"events/*.h"
"networkEditor/*.h"
"../icons/WIcons.h"
"commandPrompt/*.h"
"commandPrompt/*.cpp"
)
FILE
(
GLOB GUI_QT4_SRC
"*.cpp"
"guiElements/*.cpp"
"controlPanel/*.cpp"
"events/*.cpp"
"networkEditor/*.cpp"
"*.h"
"guiElements/*.h"
"networkEditor/layout/*.cpp"
"controlPanel/*.h"
"events/*.h"
"networkEditor/*.h"
"../icons/WIcons.h"
"commandPrompt/*.h"
"commandPrompt/*.cpp"
"networkEditor/layout/*.h"
)
IF
(
CMAKE_HOST_SYSTEM MATCHES Darwin
)
FILE
(
GLOB GUIQT4_PLATFORMDEPENDENT_SRC
"platformDependent/WQtGLWidgetMac.cpp"
...
...
src/gui/qt4/networkEditor/WQtNetworkArrow.cpp
View file @
4580209e
...
...
@@ -157,3 +157,4 @@ void WQtNetworkArrow::changeColor( QColor color )
m_color
=
color
;
setPen
(
QPen
(
m_color
,
2
,
Qt
::
SolidLine
,
Qt
::
RoundCap
,
Qt
::
RoundJoin
)
);
}
src/gui/qt4/networkEditor/WQtNetworkArrow.h
View file @
4580209e
...
...
@@ -117,6 +117,7 @@ public:
*/
QVariant
itemChange
(
GraphicsItemChange
change
,
const
QVariant
&
value
);
protected:
/**
...
...
src/gui/qt4/networkEditor/WQtNetworkEditor.cpp
View file @
4580209e
...
...
@@ -28,8 +28,6 @@
#include <boost/shared_ptr.hpp>
#include <QtGui/QDockWidget>
#include <QtGui/QVBoxLayout>
#include <QtGui/QKeyEvent>
#include <QtGui/QGraphicsView>
#include <QtGui/QGraphicsItem>
...
...
@@ -59,27 +57,27 @@ WQtNetworkEditor::WQtNetworkEditor( WMainWindow* parent )
setObjectName
(
"Module Graph Dock"
);
m_mainWindow
=
parent
;
m_
panel
=
new
QWidget
(
this
);
QWidget
*
panel
=
new
QWidget
(
this
);
m_
view
=
new
QGraphicsView
();
m_
view
->
setDragMode
(
QGraphicsView
::
RubberBandDrag
);
m_
view
->
setRenderHint
(
QPainter
::
Antialiasing
);
m_
view
->
setMinimumSize
(
20
,
20
);
QGraphicsView
*
view
=
new
QGraphicsView
();
view
->
setDragMode
(
QGraphicsView
::
RubberBandDrag
);
view
->
setRenderHint
(
QPainter
::
Antialiasing
);
view
->
setMinimumSize
(
20
,
20
);
m_scene
=
new
WQtNetworkScene
();
// m_scene->setSceneRect( -200.0, -200.0, 400.0, 400.0 );
m_scene
->
setSceneRect
(
m_scene
->
itemsBoundingRect
()
);
m_
view
->
setScene
(
m_scene
);
view
->
setScene
(
m_scene
);
m_
layout
=
new
QVBoxLayout
;
m_layout
->
addWidget
(
m_
view
);
QVBoxLayout
*
layout
=
new
QVBoxLayout
;
layout
->
addWidget
(
view
);
m_panel
->
setLayout
(
m_
layout
);
panel
->
setLayout
(
layout
);
this
->
setAllowedAreas
(
Qt
::
AllDockWidgetAreas
);
this
->
setFeatures
(
QDockWidget
::
DockWidgetClosable
|
QDockWidget
::
DockWidgetMovable
|
QDockWidget
::
DockWidgetFloatable
);
setWidget
(
m_
panel
);
setWidget
(
panel
);
connect
(
m_scene
,
SIGNAL
(
selectionChanged
()
),
this
,
SLOT
(
selectItem
()
)
);
// this fakeitem is added to the scene to get a better behavior of the forced
...
...
@@ -92,10 +90,13 @@ WQtNetworkEditor::WQtNetworkEditor( WMainWindow* parent )
fake
->
setFlag
(
QGraphicsItem
::
ItemIsMovable
,
true
);
m_scene
->
addItem
(
fake
);
m_scene
->
setFakeItem
(
fake
);
m_layout
=
new
WNetworkLayout
();
}
WQtNetworkEditor
::~
WQtNetworkEditor
()
{
delete
m_layout
;
}
void
WQtNetworkEditor
::
selectItem
()
...
...
@@ -180,7 +181,7 @@ void WQtNetworkEditor::addModule( boost::shared_ptr< WModule > module )
m_scene
->
addItem
(
netItem
);
itemMoved
();
//
itemMoved();
}
bool
WQtNetworkEditor
::
event
(
QEvent
*
event
)
...
...
@@ -194,7 +195,11 @@ bool WQtNetworkEditor::event( QEvent* event )
{
WLogger
::
getLogger
()
->
addLogMessage
(
"Inserting
\"
"
+
e1
->
getModule
()
->
getName
()
+
"
\"
."
,
"NetworkEditor"
,
LL_DEBUG
);
addModule
(
e1
->
getModule
()
);
//addModule( e1->getModule() );
WQtNetworkItem
*
item
=
new
WQtNetworkItem
(
this
,
e1
->
getModule
()
);
m_items
.
push_back
(
item
);
m_layout
->
addItem
(
item
);
m_scene
->
addItem
(
item
);
}
//TODO(skiunke): disablen des moduls solange nicht rdy!
...
...
@@ -240,8 +245,8 @@ bool WQtNetworkEditor::event( QEvent* event )
return
true
;
}
WLogger
::
getLogger
()
->
addLogMessage
(
"Connecting
\"
"
+
e
->
getInput
()
->
getModule
()
->
getName
()
+
"
\"
and
\"
"
+
e
->
getOutput
()
->
getModule
()
->
getName
()
+
"
\"
."
,
"NetworkEditor"
,
LL_DEBUG
);
WLogger
::
getLogger
()
->
addLogMessage
(
"Connecting
\"
"
+
e
->
getInput
()
->
getModule
()
->
getName
()
+
"
\"
and
\"
"
+
e
->
getOutput
()
->
getModule
()
->
getName
()
+
"
\"
."
,
"NetworkEditor"
,
LL_DEBUG
);
boost
::
shared_ptr
<
WModule
>
mIn
;
boost
::
shared_ptr
<
WModule
>
mOut
;
...
...
@@ -303,6 +308,8 @@ bool WQtNetworkEditor::event( QEvent* event )
arrow
->
updatePosition
();
m_scene
->
addItem
(
arrow
);
m_layout
->
connectItems
(
outItem
,
inItem
);
}
}
...
...
@@ -388,6 +395,8 @@ bool WQtNetworkEditor::event( QEvent* event )
}
if
(
ar
)
{
m_layout
->
disconnectItem
(
inItem
);
op
->
removeArrow
(
ar
);
ip
->
removeArrow
(
ar
);
if
(
ar
->
scene
()
!=
NULL
)
...
...
@@ -450,6 +459,8 @@ bool WQtNetworkEditor::event( QEvent* event )
if
(
item
!=
0
)
{
m_layout
->
removeItem
(
item
);
if
(
item
->
scene
()
!=
NULL
)
{
m_scene
->
removeItem
(
item
);
...
...
@@ -469,8 +480,7 @@ WQtNetworkItem* WQtNetworkEditor::findItemByModule( boost::shared_ptr< WModule >
for
(
QList
<
WQtNetworkItem
*
>::
const_iterator
iter
=
m_items
.
begin
();
iter
!=
m_items
.
end
();
++
iter
)
{
WQtNetworkItem
*
itemModule
=
dynamic_cast
<
WQtNetworkItem
*
>
(
*
iter
);
if
(
itemModule
&&
itemModule
->
getModule
()
==
module
)
if
(
itemModule
&&
itemModule
->
getModule
()
==
module
)
{
return
itemModule
;
}
...
...
@@ -486,29 +496,29 @@ void WQtNetworkEditor::itemMoved()
void
WQtNetworkEditor
::
timerEvent
(
QTimerEvent
*
event
)
{
Q_UNUSED
(
event
);
QList
<
WQtNetworkItem
*>
items
;
foreach
(
QGraphicsItem
*
item
,
m_scene
->
items
()
)
{
if
(
WQtNetworkItem
*
netItem
=
dynamic_cast
<
WQtNetworkItem
*>
(
item
)
)
items
<<
netItem
;
}
foreach
(
WQtNetworkItem
*
netItem
,
items
)
netItem
->
calculateForces
();
bool
itemsMoved
=
false
;
foreach
(
WQtNetworkItem
*
netItem
,
items
)
{
if
(
netItem
->
advance
()
)
itemsMoved
=
true
;
}
if
(
!
itemsMoved
)
{
killTimer
(
timerId
);
timerId
=
0
;
}
//
Q_UNUSED( event );
//
QList< WQtNetworkItem *> items;
//
foreach( QGraphicsItem *item, m_scene->items() )
//
{
//
if ( WQtNetworkItem *netItem = dynamic_cast< WQtNetworkItem *>( item ) )
//
items << netItem;
//
}
//
foreach( WQtNetworkItem *netItem, items )
//
netItem->calculateForces();
//
bool itemsMoved = false;
//
foreach( WQtNetworkItem *netItem, items )
//
{
//
if ( netItem->advance() )
//
itemsMoved = true;
//
}
//
if ( !itemsMoved )
//
{
//
killTimer( timerId );
//
timerId = 0;
//
}
}
src/gui/qt4/networkEditor/WQtNetworkEditor.h
View file @
4580209e
...
...
@@ -37,11 +37,13 @@
#include "../../../kernel/modules/data/WMData.h"
#include "../WQtCombinerToolbar.h"
#include "
WQtNetworkScene
.h"
#include "
layout/WNetworkLayout
.h"
#include "WQtNetworkItem.h"
#include "WQtNetworkScene.h"
// forward declaration
class
WMainWindow
;
class
WNetworkLayout
;
/**
* Container widget to hold the WQtNetworkScene
...
...
@@ -121,11 +123,13 @@ private:
WQtNetworkScene
*
m_scene
;
//!< QGraphicsScene
QGraphicsView
*
m_view
;
//!< QGraphicsView
//QGraphicsView* m_view; //!< QGraphicsView
WNetworkLayout
*
m_layout
;
//!< the object that handels the layout
QWidget
*
m_panel
;
//!< panel
//
QWidget* m_panel; //!< panel
QVBoxLayout
*
m_layout
;
//!< layout
//
QVBoxLayout* m_layout; //!< layout
QList
<
WQtNetworkItem
*
>
m_items
;
//!< a list of the WQtNetworkItems in the WQtNetworkScene
...
...
src/gui/qt4/networkEditor/WQtNetworkItem.cpp
View file @
4580209e
...
...
@@ -235,6 +235,11 @@ QList< WQtNetworkOutputPort *> WQtNetworkItem::getOutPorts()
return
m_outPorts
;
}
WNetworkLayoutItem
*
WQtNetworkItem
::
getLayoutItem
()
{
return
m_layoutItem
;
}
void
WQtNetworkItem
::
fitLook
()
{
if
(
m_text
!=
0
)
...
...
@@ -425,3 +430,4 @@ bool WQtNetworkItem::advance()
return
true
;
}
src/gui/qt4/networkEditor/WQtNetworkItem.h
View file @
4580209e
...
...
@@ -29,11 +29,14 @@
#include <QtGui/QGraphicsTextItem>
#include <QtGui/QPainter>
#include <QtGui/QColor>
#include "../../../kernel/WModule.h"
#include "layout/WNetworkLayoutItem.h"
#include "WQtNetworkInputPort.h"
#include "WQtNetworkOutputPort.h"
class
WNetworkLayoutItem
;
class
WQtNetworkEditor
;
class
QGraphicsWidget
;
...
...
@@ -43,6 +46,7 @@ class QGraphicsWidget;
*/
class
WQtNetworkItem
:
public
QGraphicsRectItem
{
friend
class
WNetworkLayoutItem
;
public:
/**
* Constructs new item in the network scene.
...
...
@@ -123,6 +127,11 @@ public:
*/
boost
::
shared_ptr
<
WModule
>
getModule
();
/**
* returns the layout item for this network item, layout item is set through the layout item (friend)
**/
WNetworkLayoutItem
*
getLayoutItem
();
/**
* Here the module can be enabled when the WModule is ready.
* \param active true if module is ready.
...
...
@@ -200,7 +209,6 @@ protected:
*/
void
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
w
);
private:
boost
::
shared_ptr
<
WModule
>
m_module
;
//!< the module
...
...
@@ -221,10 +229,12 @@ private:
QGraphicsTextItem
*
m_text
;
//!< the caption
QGraphicsTextItem
*
m_subtitle
;
//!< the caption
QGraphicsTextItem
*
m_subtitle
;
//!< the caption
QPointF
m_newPos
;
//!< the new position in the WQtNetworkScene
WQtNetworkEditor
*
m_networkEditor
;
//!< the related WQtNetworkEditor
WNetworkLayoutItem
*
m_layoutItem
;
//!< the layout item
};
#endif // WQTNETWORKITEM_H
src/gui/qt4/networkEditor/layout/WNetworkLayout.cpp
0 → 100644
View file @
4580209e
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#include "WNetworkLayoutGlobals.h"
#include "WNetworkLayout.h"
WNetworkLayout
::
WNetworkLayout
()
{
}
WNetworkLayout
::~
WNetworkLayout
()
{
for
(
std
::
list
<
WNetworkLayoutItem
*
>::
iterator
iter
=
laneList
.
begin
();
iter
!=
laneList
.
end
();
++
iter
)
{
delete
*
iter
;
}
}
void
WNetworkLayout
::
addItem
(
WQtNetworkItem
*
item
)
{
WNetworkLayoutItem
*
layoutItem
=
new
WNetworkLayoutItem
(
item
);
if
(
laneList
.
size
()
!=
0
)
{
laneList
.
back
()
->
setNeighbour
(
layoutItem
);
QPointF
pos
(
laneList
.
back
()
->
getPos
()
);
pos
.
setX
(
pos
.
x
()
+
laneList
.
back
()
->
getWidth
()
);
layoutItem
->
setPos
(
pos
);
}
else
{
layoutItem
->
setPos
(
QPointF
(
0
,
0
)
);
}
laneList
.
push_back
(
layoutItem
);
}
void
WNetworkLayout
::
connectItems
(
WQtNetworkItem
*
parent
,
WQtNetworkItem
*
child
)
{
if
(
child
->
getLayoutItem
()
->
getParent
()
==
NULL
)
{
// update linked list & move item into the parents lane
for
(
std
::
list
<
WNetworkLayoutItem
*
>::
iterator
iter
=
laneList
.
begin
();
iter
!=
laneList
.
end
();
++
iter
)
{
if
(
(
*
iter
)
->
getNeighbour
()
==
child
->
getLayoutItem
()
)
{
(
*
iter
)
->
setNeighbour
(
child
->
getLayoutItem
()
->
getNeighbour
()
);
}
}
}
child
->
getLayoutItem
()
->
setParent
(
parent
->
getLayoutItem
()
);
laneList
.
pop_back
();
}
void
WNetworkLayout
::
disconnectItem
(
WQtNetworkItem
*
child
)
{
// disconnect items
// move child to new lane
laneList
.
back
()
->
setNeighbour
(
child
->
getLayoutItem
()
);
QPointF
pos
(
laneList
.
back
()
->
getPos
()
);
pos
.
setX
(
pos
.
x
()
+
laneList
.
back
()
->
getWidth
()
);
child
->
getLayoutItem
()
->
disconnectFromParent
(
pos
);
laneList
.
push_back
(
child
->
getLayoutItem
()
);
}
void
WNetworkLayout
::
removeItem
(
WQtNetworkItem
*
item
)
{
// remove the item:
// update lane info
if
(
item
->
getLayoutItem
()
==
laneList
.
front
()
)
{
if
(
laneList
.
size
()
>
1
)
{
item
->
getLayoutItem
()
->
getNeighbour
()
->
setPos
(
item
->
getLayoutItem
()
->
getPos
()
);
}
laneList
.
pop_front
();
}
else
{
for
(
std
::
list
<
WNetworkLayoutItem
*
>::
iterator
iter
=
laneList
.
begin
();
iter
!=
laneList
.
end
();
++
iter
)
{
if
(
(
*
iter
)
->
getNeighbour
()
==
item
->
getLayoutItem
()
)
{
(
*
iter
)
->
setNeighbour
(
item
->
getLayoutItem
()
->
getNeighbour
()
);
if
(
item
->
getLayoutItem
()
->
getNeighbour
()
!=
NULL
)
{
// update the position of all lanes( -> items ) following the removed item
(
*
iter
)
->
getNeighbour
()
->
setPos
(
item
->
getLayoutItem
()
->
getPos
()
);
}
laneList
.
erase
(
++
iter
);
break
;
}
}
}
}
src/gui/qt4/networkEditor/layout/WNetworkLayout.h
0 → 100644
View file @
4580209e
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#ifndef WNETWORKLAYOUT_H
#define WNETWORKLAYOUT_H
#include <list>
#include "WNetworkLayoutItem.h"
/**
* TODO
**/
class
WNetworkLayout
{
public:
/**
* constructor
**/
WNetworkLayout
();
/**
* destructor
**/
~
WNetworkLayout
();
/**
* add an item to the layout, creates new network layout item
*
* /param item the new network item
**/
void
addItem
(
WQtNetworkItem
*
item
);
/**
* connect the two items, moves the 'end' item to the lane of 'start'
**/
void
connectItems
(
WQtNetworkItem
*
start
,
WQtNetworkItem
*
end
);
/**
* disconnects the child from the parent item and moves the item to a new, empty lane
**/
void
disconnectItem
(
WQtNetworkItem
*
child
);
/**
* remove an item from the layout, should only be called when in- and out-degree of the item
* equals zero, if this is not the case disconnect items beforehand
*
* \param item the item thats going to be removed
**/
void
removeItem
(
WQtNetworkItem
*
item
);
protected:
private:
//std::pair< WNetworkLayoutItem *, WNetworkLayoutItem * > laneList; //<! list allows iteration over lanes
bool
m_array
[
30
][
1000
];
std
::
list
<
WNetworkLayoutItem
*
>
laneList
;
//<! list allows iteration over lanes
};
#endif // WNETWORKLAYOUT_H
src/gui/qt4/networkEditor/layout/WNetworkLayoutGlobals.h
0 → 100644
View file @
4580209e
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#ifndef WNETWORKLAYOUTGLOBALS_H
#define WNETWORKLAYOUTGLOBALS_H
// The size of the grid
#define WNETWORKLAYOUT_GRIDSIZE 240
#endif // WNETWORKLAYOUTGLOBALS_H
src/gui/qt4/networkEditor/layout/WNetworkLayoutItem.cpp
0 → 100644
View file @
4580209e
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#include <QtCore/QPointF>
#include "WNetworkLayoutGlobals.h"
#include "WNetworkLayoutItem.h"
WNetworkLayoutItem
::
WNetworkLayoutItem
(
WQtNetworkItem
*
item
)
{
m_item
=
item
;
m_width
=
m_item
->
m_width
*
1.2
;
// 20% is boarder
m_parent
=
NULL
;
m_neighbour
=
NULL
;
m_item
->
m_layoutItem
=
this
;
}
WNetworkLayoutItem
::~
WNetworkLayoutItem
()
{
for
(
std
::
list
<
WNetworkLayoutItem
*
>::
iterator
iter
=
children
.
begin
();
iter
!=
children
.
end
();
++
iter
)
{
delete
*
iter
;
}
m_item
->
m_layoutItem
=
NULL
;
}
void
WNetworkLayoutItem
::
addChild
(
WNetworkLayoutItem
*
child
,
float
width
)
{
children
.
push_back
(
child
);
if
(
children
.
size
()
>
1
)
{
m_width
+=
width
;
updateLayoutPos
();
}
else
{
if
(
m_width
!=
width
)
{
m_width
=
width
;
updateLayoutPos
();
}
}
}
void
WNetworkLayoutItem
::
disconnectFromParent
(
QPointF
newPos
)
{
m_parent
->
removeChild
(
this
);
m_parent
=
NULL
;
setPos
(
newPos
);
}
WNetworkLayoutItem
*
WNetworkLayoutItem
::
getParent
()
{
return
m_parent
;
}
WNetworkLayoutItem
*
WNetworkLayoutItem
::
getNeighbour
()
{
return
m_neighbour
;