OpenWalnut
1.5.0dev
|
Layout manager class for a QGraphicsScene. More...
#include <WQtNetworkSceneLayout.h>
Classes | |
struct | LayoutFlags |
Some flags used in the layouter as defaults. More... | |
Public Types | |
typedef std::shared_ptr< WQtNetworkSceneLayout > | SPtr |
Convenience typedef for a std::shared_ptr< WQtNetworkSceneLayout >. More... | |
typedef std::shared_ptr< const WQtNetworkSceneLayout > | ConstSPtr |
Convenience typedef for a std::shared_ptr< const WQtNetworkSceneLayout >. More... | |
Public Member Functions | |
WQtNetworkSceneLayout (WQtNetworkScene *scene, WQtNetworkItemGrid *grid) | |
Default constructor. More... | |
virtual | ~WQtNetworkSceneLayout () |
Destructor. More... | |
virtual void | addItem (WQtNetworkItem *item) |
Add an item to the layout. More... | |
virtual void | removeItem (WQtNetworkItem *item) |
Remove the item from the layout. More... | |
virtual void | connection (WQtNetworkItem *outItem, WQtNetworkItem *inItem) |
Two module got connected. More... | |
void | disconnection (WQtNetworkItem *outItem, WQtNetworkItem *inItem) |
Two modules got disconnected. More... | |
void | snapTemporarily (WQtNetworkItem *item, QPointF worldCoords, bool noPhysicalMove=false) |
Snap the item to the nearest layout element. More... | |
void | snapAccept (WQtNetworkItem *item, QPointF worldCoords) |
Accept the current item position and update layout accordingly. More... | |
void | blendIn () |
Allows blending in the underlaying layout structure. More... | |
void | blendOut () |
Allows blending out the underlaying layout structure. More... | |
QRectF | getBoundingBox () |
Return the bounding box of this layout. More... | |
WQtNetworkItemGrid * | getGrid () const |
Get the grid used for the layout. More... | |
void | setModuleDefaultPosition (WModule::SPtr module, QPoint coord) |
Set a default position for a given module. More... | |
void | setModuleDefaultFlags (WModule::SPtr module, bool layedOut, bool manuallyLayedOut) |
Set a default flag combination for the given module. More... | |
Private Types | |
typedef std::map< std::string, QPoint > | ModuleDefaultCoordinates |
Map between module UUID and network coord. More... | |
typedef std::map< std::string, LayoutFlags > | ModuleDefaultFlags |
Map between module UUID and network flags. More... | |
typedef std::pair< std::string, QPoint > | ModuleDefaultCoordinatesItem |
The type inside the map. More... | |
Private Attributes | |
WQtNetworkItemGrid * | m_grid |
we use a grid to place the items More... | |
WSharedAssociativeContainer< ModuleDefaultCoordinates > | m_moduleDefaultCoords |
The mapping of network coordinates for each module. More... | |
WSharedAssociativeContainer< ModuleDefaultFlags > | m_moduleDefaultFlags |
The mapping of network flags for each module. More... | |
Layout manager class for a QGraphicsScene.
As the QGraphicsScene itself does not provide virtual methods for item addition and removal, we need to write a separate layout class.
Definition at line 45 of file WQtNetworkSceneLayout.h.
typedef std::shared_ptr< const WQtNetworkSceneLayout > WQtNetworkSceneLayout::ConstSPtr |
Convenience typedef for a std::shared_ptr< const WQtNetworkSceneLayout >.
Definition at line 56 of file WQtNetworkSceneLayout.h.
|
private |
Map between module UUID and network coord.
Definition at line 167 of file WQtNetworkSceneLayout.h.
|
private |
The type inside the map.
Definition at line 193 of file WQtNetworkSceneLayout.h.
|
private |
Map between module UUID and network flags.
Definition at line 188 of file WQtNetworkSceneLayout.h.
typedef std::shared_ptr< WQtNetworkSceneLayout > WQtNetworkSceneLayout::SPtr |
Convenience typedef for a std::shared_ptr< WQtNetworkSceneLayout >.
Definition at line 51 of file WQtNetworkSceneLayout.h.
WQtNetworkSceneLayout::WQtNetworkSceneLayout | ( | WQtNetworkScene * | scene, |
WQtNetworkItemGrid * | grid | ||
) |
Default constructor.
scene | the scene to manage |
grid | the grid to work in |
Definition at line 34 of file WQtNetworkSceneLayout.cpp.
|
virtual |
Destructor.
Definition at line 40 of file WQtNetworkSceneLayout.cpp.
|
virtual |
Add an item to the layout.
item | the item to add. |
Definition at line 45 of file WQtNetworkSceneLayout.cpp.
References WQtNetworkItemGrid::getFirstFreeColumn(), WQtNetworkItem::getModule(), WSharedObject< T >::getReadTicket(), m_grid, m_moduleDefaultCoords, m_moduleDefaultFlags, WQtNetworkItemGrid::setItem(), WQtNetworkItem::setLayedOut(), and WQtNetworkItem::setManuallyPlaced().
Referenced by WQtNetworkEditor::event().
void WQtNetworkSceneLayout::blendIn | ( | ) |
Allows blending in the underlaying layout structure.
Definition at line 157 of file WQtNetworkSceneLayout.cpp.
References WQtNetworkItemGrid::blendIn(), and m_grid.
Referenced by WQtNetworkItem::mousePressEvent().
void WQtNetworkSceneLayout::blendOut | ( | ) |
Allows blending out the underlaying layout structure.
Definition at line 162 of file WQtNetworkSceneLayout.cpp.
References WQtNetworkItemGrid::blendOut(), and m_grid.
Referenced by WQtNetworkItem::mouseReleaseEvent().
|
virtual |
Two module got connected.
outItem | the output module |
inItem | the input module |
Definition at line 82 of file WQtNetworkSceneLayout.cpp.
References WQtNetworkItemGrid::isOccupied(), m_grid, WQtNetworkItemGrid::moveItem(), WQtNetworkItem::setLayedOut(), WQtNetworkItem::wasLayedOut(), WQtNetworkItem::wasManuallyPlaced(), and WQtNetworkItemGrid::whereIs().
Referenced by WQtNetworkEditor::event().
void WQtNetworkSceneLayout::disconnection | ( | WQtNetworkItem * | outItem, |
WQtNetworkItem * | inItem | ||
) |
Two modules got disconnected.
outItem | the output module |
inItem | the input module |
Definition at line 108 of file WQtNetworkSceneLayout.cpp.
Referenced by WQtNetworkEditor::event().
QRectF WQtNetworkSceneLayout::getBoundingBox | ( | ) |
Return the bounding box of this layout.
Definition at line 167 of file WQtNetworkSceneLayout.cpp.
References WQtNetworkItemGrid::boundingRect(), and m_grid.
Referenced by WQtNetworkEditor::event(), and WQtNetworkEditor::updateSceneRect().
WQtNetworkItemGrid * WQtNetworkSceneLayout::getGrid | ( | ) | const |
Get the grid used for the layout.
Definition at line 172 of file WQtNetworkSceneLayout.cpp.
References m_grid.
Referenced by WQtNetworkEditorProjectFileIO::done(), WQtNetworkItem::mouseMoveEvent(), and WQtNetworkEditorProjectFileIO::save().
|
virtual |
Remove the item from the layout.
item | the item to remove |
Definition at line 76 of file WQtNetworkSceneLayout.cpp.
References m_grid, and WQtNetworkItemGrid::removeItem().
Referenced by WQtNetworkItem::removalAnimationDone().
void WQtNetworkSceneLayout::setModuleDefaultFlags | ( | WModule::SPtr | module, |
bool | layedOut, | ||
bool | manuallyLayedOut | ||
) |
Set a default flag combination for the given module.
The layouter might use them.
module | the module |
layedOut | flag if the item was layed out already. |
manuallyLayedOut | flag if the item was manually layed out. |
Definition at line 183 of file WQtNetworkSceneLayout.cpp.
References WSharedObject< T >::getWriteTicket(), and m_moduleDefaultFlags.
Referenced by WQtNetworkEditorProjectFileIO::done().
void WQtNetworkSceneLayout::setModuleDefaultPosition | ( | WModule::SPtr | module, |
QPoint | coord | ||
) |
Set a default position for a given module.
The layouter will position a module at the given coordinate now, or in future.
module | the module |
coord | the coordinate |
Definition at line 177 of file WQtNetworkSceneLayout.cpp.
References WSharedObject< T >::getWriteTicket(), and m_moduleDefaultCoords.
Referenced by WQtNetworkEditorProjectFileIO::done().
void WQtNetworkSceneLayout::snapAccept | ( | WQtNetworkItem * | item, |
QPointF | worldCoords | ||
) |
Accept the current item position and update layout accordingly.
item | the item |
worldCoords | world space coordinates |
Definition at line 135 of file WQtNetworkSceneLayout.cpp.
References WQtNetworkItemGrid::findNearestCell(), WQtNetworkItemGrid::highlightCell(), m_grid, WQtNetworkItemGrid::moveItem(), WQtNetworkItemGrid::physicalMoveTo(), WQtNetworkItem::setManuallyPlaced(), and WQtNetworkItemGrid::whereIs().
Referenced by WQtNetworkItem::mouseReleaseEvent().
void WQtNetworkSceneLayout::snapTemporarily | ( | WQtNetworkItem * | item, |
QPointF | worldCoords, | ||
bool | noPhysicalMove = false |
||
) |
Snap the item to the nearest layout element.
The coordinates specified are in world space. The snapping is temporary. You can undo it or accept it later to actually modify layout.
item | the item |
worldCoords | world space coordinates |
noPhysicalMove | disable movement of item if you handle it for yourself |
Definition at line 113 of file WQtNetworkSceneLayout.cpp.
References WQtNetworkItemGrid::findNearestCell(), WQtNetworkItemGrid::highlightCell(), WQtNetworkItemGrid::isOccupied(), m_grid, WQtNetworkItemGrid::physicalMoveTo(), and WQtNetworkItemGrid::whereIs().
Referenced by WQtNetworkItem::mouseMoveEvent().
|
private |
we use a grid to place the items
Definition at line 162 of file WQtNetworkSceneLayout.h.
Referenced by addItem(), blendIn(), blendOut(), connection(), getBoundingBox(), getGrid(), removeItem(), snapAccept(), and snapTemporarily().
|
private |
The mapping of network coordinates for each module.
This is wrapped by a thread save WSharedObject, since the loader might run in a thread that is not the GUI thread.
Definition at line 199 of file WQtNetworkSceneLayout.h.
Referenced by addItem(), and setModuleDefaultPosition().
|
private |
The mapping of network flags for each module.
This is wrapped by a thread save WSharedObject, since the loader might run in a thread that is not the GUI thread.
Definition at line 205 of file WQtNetworkSceneLayout.h.
Referenced by addItem(), and setModuleDefaultFlags().