OpenWalnut  1.5.0dev
Classes | Public Types | Public Member Functions | Private Types | Private Attributes | List of all members
WQtNetworkSceneLayout Class Reference

Layout manager class for a QGraphicsScene. More...

#include <WQtNetworkSceneLayout.h>

+ Collaboration diagram for WQtNetworkSceneLayout:

Classes

struct  LayoutFlags
 Some flags used in the layouter as defaults. More...
 

Public Types

typedef std::shared_ptr< WQtNetworkSceneLayoutSPtr
 Convenience typedef for a std::shared_ptr< WQtNetworkSceneLayout >. More...
 
typedef std::shared_ptr< const WQtNetworkSceneLayoutConstSPtr
 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...
 
WQtNetworkItemGridgetGrid () 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, LayoutFlagsModuleDefaultFlags
 Map between module UUID and network flags. More...
 
typedef std::pair< std::string, QPoint > ModuleDefaultCoordinatesItem
 The type inside the map. More...
 

Private Attributes

WQtNetworkItemGridm_grid
 we use a grid to place the items More...
 
WSharedAssociativeContainer< ModuleDefaultCoordinatesm_moduleDefaultCoords
 The mapping of network coordinates for each module. More...
 
WSharedAssociativeContainer< ModuleDefaultFlagsm_moduleDefaultFlags
 The mapping of network flags for each module. More...
 

Detailed Description

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.

Member Typedef Documentation

◆ ConstSPtr

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.

◆ ModuleDefaultCoordinates

typedef std::map< std::string, QPoint > WQtNetworkSceneLayout::ModuleDefaultCoordinates
private

Map between module UUID and network coord.

Definition at line 167 of file WQtNetworkSceneLayout.h.

◆ ModuleDefaultCoordinatesItem

typedef std::pair< std::string, QPoint > WQtNetworkSceneLayout::ModuleDefaultCoordinatesItem
private

The type inside the map.

Definition at line 193 of file WQtNetworkSceneLayout.h.

◆ ModuleDefaultFlags

typedef std::map< std::string, LayoutFlags > WQtNetworkSceneLayout::ModuleDefaultFlags
private

Map between module UUID and network flags.

Definition at line 188 of file WQtNetworkSceneLayout.h.

◆ SPtr

Convenience typedef for a std::shared_ptr< WQtNetworkSceneLayout >.

Definition at line 51 of file WQtNetworkSceneLayout.h.

Constructor & Destructor Documentation

◆ WQtNetworkSceneLayout()

WQtNetworkSceneLayout::WQtNetworkSceneLayout ( WQtNetworkScene scene,
WQtNetworkItemGrid grid 
)

Default constructor.

Parameters
scenethe scene to manage
gridthe grid to work in

Definition at line 34 of file WQtNetworkSceneLayout.cpp.

◆ ~WQtNetworkSceneLayout()

WQtNetworkSceneLayout::~WQtNetworkSceneLayout ( )
virtual

Destructor.

Definition at line 40 of file WQtNetworkSceneLayout.cpp.

Member Function Documentation

◆ addItem()

void WQtNetworkSceneLayout::addItem ( WQtNetworkItem item)
virtual

Add an item to the layout.

Parameters
itemthe 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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ blendIn()

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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ blendOut()

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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ connection()

void WQtNetworkSceneLayout::connection ( WQtNetworkItem outItem,
WQtNetworkItem inItem 
)
virtual

Two module got connected.

Parameters
outItemthe output module
inItemthe 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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ disconnection()

void WQtNetworkSceneLayout::disconnection ( WQtNetworkItem outItem,
WQtNetworkItem inItem 
)

Two modules got disconnected.

Parameters
outItemthe output module
inItemthe input module

Definition at line 108 of file WQtNetworkSceneLayout.cpp.

Referenced by WQtNetworkEditor::event().

+ Here is the caller graph for this function:

◆ getBoundingBox()

QRectF WQtNetworkSceneLayout::getBoundingBox ( )

Return the bounding box of this layout.

Returns
the bb

Definition at line 167 of file WQtNetworkSceneLayout.cpp.

References WQtNetworkItemGrid::boundingRect(), and m_grid.

Referenced by WQtNetworkEditor::event(), and WQtNetworkEditor::updateSceneRect().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getGrid()

WQtNetworkItemGrid * WQtNetworkSceneLayout::getGrid ( ) const

Get the grid used for the layout.

Returns
the grid.

Definition at line 172 of file WQtNetworkSceneLayout.cpp.

References m_grid.

Referenced by WQtNetworkEditorProjectFileIO::done(), WQtNetworkItem::mouseMoveEvent(), and WQtNetworkEditorProjectFileIO::save().

+ Here is the caller graph for this function:

◆ removeItem()

void WQtNetworkSceneLayout::removeItem ( WQtNetworkItem item)
virtual

Remove the item from the layout.

Parameters
itemthe item to remove

Definition at line 76 of file WQtNetworkSceneLayout.cpp.

References m_grid, and WQtNetworkItemGrid::removeItem().

Referenced by WQtNetworkItem::removalAnimationDone().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setModuleDefaultFlags()

void WQtNetworkSceneLayout::setModuleDefaultFlags ( WModule::SPtr  module,
bool  layedOut,
bool  manuallyLayedOut 
)

Set a default flag combination for the given module.

The layouter might use them.

Parameters
modulethe module
layedOutflag if the item was layed out already.
manuallyLayedOutflag 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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setModuleDefaultPosition()

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.

Parameters
modulethe module
coordthe coordinate

Definition at line 177 of file WQtNetworkSceneLayout.cpp.

References WSharedObject< T >::getWriteTicket(), and m_moduleDefaultCoords.

Referenced by WQtNetworkEditorProjectFileIO::done().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ snapAccept()

void WQtNetworkSceneLayout::snapAccept ( WQtNetworkItem item,
QPointF  worldCoords 
)

Accept the current item position and update layout accordingly.

Parameters
itemthe item
worldCoordsworld 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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ snapTemporarily()

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.

Parameters
itemthe item
worldCoordsworld space coordinates
noPhysicalMovedisable 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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_grid

WQtNetworkItemGrid* WQtNetworkSceneLayout::m_grid
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().

◆ m_moduleDefaultCoords

WSharedAssociativeContainer< ModuleDefaultCoordinates > WQtNetworkSceneLayout::m_moduleDefaultCoords
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().

◆ m_moduleDefaultFlags

WSharedAssociativeContainer< ModuleDefaultFlags > WQtNetworkSceneLayout::m_moduleDefaultFlags
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().


The documentation for this class was generated from the following files: