25 #include "core/common/WLogger.h"
27 #include "WQtNetworkEditor.h"
28 #include "WQtNetworkScene.h"
29 #include "WQtNetworkItem.h"
30 #include "WQtNetworkItemGrid.h"
32 #include "WQtNetworkSceneLayout.h"
50 ModuleDefaultCoordinates::const_iterator defaultCoord = r->get().find( item->
getModule()->getUUID() );
51 if( defaultCoord == r->get().end() )
63 ModuleDefaultFlags::const_iterator defaultFlags = rflags->get().find( item->
getModule()->getUUID() );
64 if( defaultFlags != rflags->get().end() )
66 item->
setLayedOut( ( *defaultFlags ).second.m_layedOut );
95 QPoint target( out.x(), out.y() + 1 );
119 if( oldCell != cell )
122 m_grid->
highlightCell( cell, isUsed ? QColor( 230, 40, 40, 128 ) : QColor( 90, 220, 90, 128 ) );
129 if( !noPhysicalMove )
144 if( oldCell != newCell )
180 w->get()[ module->getUUID() ] = coord;
186 w->get()[ module->getUUID() ].m_layedOut = layedOut;
187 w->get()[ module->getUUID() ].m_manuallyLayedOut = manuallyLayedOut;
std::shared_ptr< WModule > SPtr
Shared pointer to a WModule.
Implement a virtual grid for placing QGraphicsItems.
bool setItem(QGraphicsItem *item, int col, int row)
Set the specified item to the specified position.
virtual QRectF boundingRect() const
The bounding area of the item.
virtual QPoint whereIs(QGraphicsItem *item)
Find the position of the specified item.
bool moveItem(QGraphicsItem *item, int col, int row)
Move item from its current position to the specified one.
virtual QPoint findNearestCell(QPointF worldSpace)
Find the nearest cell matching the specified world coordinates.
virtual void physicalMoveTo(QGraphicsItem *item, int col, int row, bool animate=true)
Move the item to the position physically.
void blendOut()
Allows blending out the underlaying layout structure.
void blendIn()
Allows blending in the underlaying layout structure.
void highlightCell(QPoint cell, QColor color)
Highlights the specified cell.
void removeItem(int col, int row)
Remove the item at the given position.
int getFirstFreeColumn() const
Return the index of the first empty column.
bool isOccupied(int col, int row)
Is there an element at the given position?
This class represents a WModule as QGraphicsItem and contains a reference to its in- and outports.
void setLayedOut(bool layedOut=true)
Marks the item as already layed out.
void setManuallyPlaced(bool manual=true)
Mark item as manually placed.
std::shared_ptr< WModule > getModule()
Get the WModule represented by this object.
bool wasLayedOut() const
Checks whether the item was layed out earlier.
bool wasManuallyPlaced() const
Item was placed by hand.
virtual void addItem(WQtNetworkItem *item)
Add an item to the layout.
WSharedAssociativeContainer< ModuleDefaultCoordinates > m_moduleDefaultCoords
The mapping of network coordinates for each module.
void snapAccept(WQtNetworkItem *item, QPointF worldCoords)
Accept the current item position and update layout accordingly.
void blendOut()
Allows blending out the underlaying layout structure.
WSharedAssociativeContainer< ModuleDefaultFlags > m_moduleDefaultFlags
The mapping of network flags for each module.
WQtNetworkSceneLayout(WQtNetworkScene *scene, WQtNetworkItemGrid *grid)
Default constructor.
WQtNetworkItemGrid * m_grid
we use a grid to place the items
virtual void connection(WQtNetworkItem *outItem, WQtNetworkItem *inItem)
Two module got connected.
virtual void removeItem(WQtNetworkItem *item)
Remove the item from the layout.
void blendIn()
Allows blending in the underlaying layout structure.
virtual ~WQtNetworkSceneLayout()
Destructor.
void setModuleDefaultFlags(WModule::SPtr module, bool layedOut, bool manuallyLayedOut)
Set a default flag combination for the given module.
WQtNetworkItemGrid * getGrid() const
Get the grid used for the layout.
void disconnection(WQtNetworkItem *outItem, WQtNetworkItem *inItem)
Two modules got disconnected.
void setModuleDefaultPosition(WModule::SPtr module, QPoint coord)
Set a default position for a given module.
QRectF getBoundingBox()
Return the bounding box of this layout.
void snapTemporarily(WQtNetworkItem *item, QPointF worldCoords, bool noPhysicalMove=false)
Snap the item to the nearest layout element.
The scene containing the whole graph.
This class provides a common interface for thread-safe access to associative containers (set,...
ReadTicket getReadTicket() const
Returns a ticket to get read access to the contained data.
WriteTicket getWriteTicket(bool suppressNotify=false) const
Returns a ticket to get write access to the contained data.