30 #include <QGraphicsItem>
31 #include <QGraphicsItemGroup>
32 #include <QGraphicsView>
35 #include "../WMainWindow.h"
36 #include "../controlPanel/WQtControlPanel.h"
37 #include "../events/WEventTypes.h"
38 #include "../events/WModuleAssocEvent.h"
39 #include "../events/WModuleConnectEvent.h"
40 #include "../events/WModuleCrashEvent.h"
41 #include "../events/WModuleDeleteEvent.h"
42 #include "../events/WModuleDisconnectEvent.h"
43 #include "../events/WModuleReadyEvent.h"
44 #include "../events/WModuleRemovedEvent.h"
45 #include "WQtNetworkEditor.h"
46 #include "WQtNetworkEditorProjectFileIO.h"
47 #include "WQtNetworkItemGrid.h"
48 #include "WQtNetworkPort.h"
49 #include "core/kernel/WKernel.h"
50 #include "core/kernel/WModule.h"
51 #include "core/kernel/WModuleFactory.h"
52 #include "core/kernel/WProjectFile.h"
53 #include "core/kernel/combiner/WDisconnectCombiner.h"
61 setObjectName(
"Module Graph Dock" );
64 setAcceptDrops(
true );
67 m_view->setMinimumSize( 20, 20 );
68 this->setFocusProxy(
m_view );
92 QTimer* updater =
new QTimer(
this );
93 updater->start( 100 );
94 connect( updater, SIGNAL( timeout() ),
this, SLOT(
updateCycle() ) );
103 return m_scene->selectedItems();
114 if( item && !item->isSelected() )
117 item->setSelected(
true );
123 std::shared_ptr< WModule > module;
124 if(
m_scene->selectedItems().size() != 0 &&
125 m_scene->selectedItems().at( 0 )->type() == WQtNetworkItem::Type )
127 if(
m_scene->selectedItems().at( 0 )->type() == WQtNetworkItem::Type )
153 if(
event->type() == WQT_ASSOC_EVENT )
160 "NetworkEditor", LL_DEBUG );
182 v->ensureVisible( item );
190 if(
event->type() == WQT_READY_EVENT )
198 "NetworkEditor", LL_WARNING );
204 "NetworkEditor", LL_DEBUG );
217 if(
event->type() == WQT_MODULE_CONNECT_EVENT )
224 "NetworkEditor", LL_WARNING );
229 "\" and \"" + e->
getOutput()->getModule()->getName() +
"\".",
"NetworkEditor", LL_DEBUG );
231 std::shared_ptr< WModule > mIn;
232 std::shared_ptr< WModule > mOut;
234 if( e->
getInput()->isInputConnector() ==
true &&
235 e->
getOutput()->isOutputConnector() ==
true )
240 else if( e->
getInput()->isOutputConnector() ==
true &&
241 e->
getOutput()->isInputConnector() ==
true )
271 iter != tmpOut.end();
286 arrow->setZValue( -1000.0 );
299 if(
event->type() == WQT_MODULE_DISCONNECT_EVENT )
306 "NetworkEditor", LL_WARNING );
311 "\" and \"" + e->
getOutput()->getCanonicalName() +
312 "\"." ,
"NetworkEditor", LL_DEBUG );
314 std::shared_ptr< WModule > mIn;
315 std::shared_ptr< WModule > mOut;
317 if( e->
getInput()->isInputConnector() ==
true &&
318 e->
getOutput()->isOutputConnector() ==
true )
323 else if( e->
getInput()->isOutputConnector() ==
true &&
324 e->
getOutput()->isInputConnector() ==
true )
354 iter != tmpOut.end();
368 iter != tmpItems.end();
383 if( ar->scene() != NULL )
401 if(
event->type() == WQT_MODULE_REMOVE_EVENT )
408 "NetworkEditor", LL_WARNING );
413 "NetworkEditor", LL_DEBUG );
427 if(
event->type() == WQT_MODULE_DELETE_EVENT )
434 "its type claims it. Ignoring event.",
435 "NetworkEditor", LL_WARNING );
440 "NetworkEditor", LL_DEBUG );
454 if(
event->type() == WQT_CRASH_EVENT )
462 "its type claims it. Ignoring event.",
463 "NetworkEditor", LL_WARNING );
468 "NetworkEditor", LL_DEBUG );
476 return WQtDockWidget::event(
event );
485 if( itemModule && itemModule->
getModule().get() == module.get() )
void addLogMessage(std::string message, std::string source="", LogLevel level=LL_DEBUG)
Appends a log message to the logging queue.
static WLogger * getLogger()
Returns pointer to the currently running logger instance.
This class contains the main window and the layout of the widgets within the window.
WQtControlPanel * getControlPanel()
Returns a pointer to the control panel object.
Event signalling a new module has been associated with the root container in the kernel.
std::shared_ptr< WModule > getModule()
Getter for the module that got associated.
Event signalling a module connection was established.
std::shared_ptr< WModuleConnector > getOutput() const
Gets the output connector involved in this connection event.
std::shared_ptr< WModuleConnector > getInput() const
Gets the input connector involved in this connection event.
Event signalling a new module has been associated with the root container in the kernel.
std::shared_ptr< WModule > getModule()
Getter for the module that got associated.
Event signalling a module item should be deleted.
WQtTreeItem * getTreeItem()
Getter for the tree item that got outdated.
Event signalling a module connection was closed.
std::shared_ptr< WModuleConnector > getInput() const
Gets the input connector involved in this connection event.
std::shared_ptr< WModuleConnector > getOutput() const
Gets the output connector involved in this connection event.
Event signalling a new module has been associated with the root container in the kernel.
std::shared_ptr< WModule > getModule()
Getter for the module that got associated.
Event signalling a module was removed from the kernel root container.
std::shared_ptr< WModule > getModule()
Getter for the module that got removed.
std::shared_ptr< WModule > SPtr
Shared pointer to a WModule.
std::shared_ptr< WProjectFileIO > SPtr
Abbreviation for a shared pointer.
static void registerParser(WProjectFileIO::SPtr parser)
Register a custom project file parser.
void deactivateModuleSelection(bool selectTopmost=true)
Used to clean the GUI from any module specify widgets.
void setActiveModule(WModule::SPtr module, bool forceUpdate=false)
Sets the module which is now active.
This Class is needed for connecting two ports and drawing a line between them.
WQtNetworkInputPort * getEndPort()
Returns the WQtNetworkInputPort where the arrow ends.
void updatePosition(QPointF deviate=QPointF())
Calculated the new position of the lines endpoints in the scene.
WQtNetworkOutputPort * getStartPort()
Returns the WQtNetworkOutputPort where the arrow starts.
IO class for writing the network editor meta data for the modules.
This class extends the basic functionality of QGraphicsView to allow comfortable panning and zooming.
void focusOn(QGraphicsItem *item)
The Item to focus on.
void selectByModule(WModule::SPtr module)
Select the item representing the given module.
void updateCycle()
Called by a timer to allow updates of all module items.
virtual bool event(QEvent *event)
Everytime a module is associated, ready, connected, disconnected, removed or deleted the kernels emit...
void selectItem()
Determines possible Connections and the propertytab.
WQtNetworkItem * findItemByModule(std::shared_ptr< WModule > module)
Simple search the WQtNetworkItem that belongs to the WModule.
WQtNetworkEditorView * getView()
Get the view handling the scene.
WQtNetworkScene * m_scene
the scene managing the items
void clearSelection()
Clears the selection.
void updateSceneRect()
Set new scene rect.
WQtNetworkSceneLayout * m_layout
the layouter of the scene
WMainWindow * m_mainWindow
Reference to the main window of the application.
QList< QGraphicsItem * > selectedItems() const
Query a list of selected items.
QList< WQtNetworkItem * > m_items
a list of the WQtNetworkItems in the WQtNetworkScene
WQtNetworkScene * getScene()
Returns the current scene.
WQtNetworkSceneLayout * getLayout()
Get the layouter of the scene.
WQtNetworkItemGrid * m_grid
we use a grid to place the items
WQtNetworkEditorView * m_view
The view controlling several scene transformations.
virtual ~WQtNetworkEditor()
destructor.
WQtNetworkEditor(WMainWindow *parent=0)
constructor
Implement a virtual grid for placing QGraphicsItems.
This class represents a WModule as QGraphicsItem and contains a reference to its in- and outports.
void activate(bool active)
Here the module can be enabled when the WModule is ready.
std::shared_ptr< WModule > getModule()
Get the WModule represented by this object.
QList< WQtNetworkInputPort * > getInPorts()
Returns the item inports.
void setCrashed()
Mark this module as crashed.
QTimeLine * die()
Animate removal and finally, instruct the owning network editor to remove the item.
QList< WQtNetworkOutputPort * > getOutPorts()
Returns the item outports.
This class represents the ports a module have.
std::shared_ptr< WModuleOutputConnector > getConnector()
Returns the WModuleOutputConnecter that belongs to this object.
virtual void removeArrow(WQtNetworkArrow *arrow)
Removes a specific arrow.
virtual void addArrow(WQtNetworkArrow *arrow)
Adds an arrow to the port.
Layout manager class for a QGraphicsScene.
virtual void addItem(WQtNetworkItem *item)
Add an item to the layout.
virtual void connection(WQtNetworkItem *outItem, WQtNetworkItem *inItem)
Two module got connected.
void disconnection(WQtNetworkItem *outItem, WQtNetworkItem *inItem)
Two modules got disconnected.
QRectF getBoundingBox()
Return the bounding box of this layout.
The scene containing the whole graph.
WModule::SPtr getModule()
Get for the module pointer.