Commit bbb729b4 authored by skiunke's avatar skiunke
Browse files

[UPDATE] kernel sends signal to networkEditor - new item is added included ports

parent fee7e4f2
......@@ -579,6 +579,11 @@ WQtDatasetBrowser* WMainWindow::getDatasetBrowser()
return m_datasetBrowser;
}
WQtNetworkEditor* WMainWindow::getNetworkEditor()
{
return m_networkEditor;
}
void WMainWindow::projectSave( const std::vector< boost::shared_ptr< WProjectFileIO > >& writer )
{
QFileDialog fd;
......
......@@ -79,6 +79,11 @@ public:
* returns a pointer to the dataset browser object
*/
WQtDatasetBrowser* getDatasetBrowser();
/**
* returns a pointer to the network editor object
*/
WQtNetworkEditor* getNetworkEditor();
/**
* returns a pointer to the ribbon menu object
......
......@@ -280,6 +280,7 @@ void WQt4Gui::slotAddDatasetOrModuleToBrowser( boost::shared_ptr< WModule > modu
{
// create a new event for this and insert it into event queue
QCoreApplication::postEvent( m_mainWindow->getDatasetBrowser(), new WModuleAssocEvent( module ) );
QCoreApplication::postEvent( m_mainWindow->getNetworkEditor(), new WModuleAssocEvent( module ) );
}
void WQt4Gui::slotAddRoiToBrowser( boost::shared_ptr< WRMROIRepresentation > roi )
......
......@@ -38,6 +38,19 @@
#include "WQtNetworkItem.h"
#include "WQtNetworkPort.h"
#include "../../../kernel/WKernel.h"
#include "../../../kernel/WModule.h"
#include "../../../kernel/WModuleFactory.h"
#include "../events/WEventTypes.h"
#include "../events/WModuleAssocEvent.h"
#include "../events/WModuleConnectEvent.h"
#include "../events/WModuleDeleteEvent.h"
#include "../events/WModuleDisconnectEvent.h"
#include "../events/WModuleReadyEvent.h"
#include "../events/WModuleRemovedEvent.h"
#include "../events/WRoiAssocEvent.h"
#include "../events/WRoiRemoveEvent.h"
WQtNetworkEditor::WQtNetworkEditor( QString title, WMainWindow* parent )
: QDockWidget( title, parent )
......@@ -65,10 +78,10 @@ WQtNetworkEditor::WQtNetworkEditor( QString title, WMainWindow* parent )
m_panel->setLayout( m_layout );
addModule(/*Qpoint, String*/);
//addModule(/*Qpoint, String*/);
addModule();
addModule();
//addModule();
this->setAllowedAreas( Qt::RightDockWidgetArea );
this->setWidget( m_panel );
......@@ -78,7 +91,7 @@ WQtNetworkEditor::~WQtNetworkEditor()
{
}
void WQtNetworkEditor::addModule()
void WQtNetworkEditor::addModule( )
{
WQtNetworkItem *netItem = new WQtNetworkItem();
......@@ -94,7 +107,7 @@ void WQtNetworkEditor::addModule()
WQtNetworkPort *ipport = new WQtNetworkPort( "B", true );
ipport->setParentItem( netItem );
QGraphicsTextItem *text = new QGraphicsTextItem( "Module " );
QGraphicsTextItem *text = new QGraphicsTextItem( "test" );
text->setParentItem( netItem );
text->setDefaultTextColor( Qt::white );
......@@ -110,3 +123,81 @@ void WQtNetworkEditor::addModule()
m_scene->addItem( netItem );
}
void WQtNetworkEditor::addModule( WModule *module )
{
WQtNetworkItem *netItem = new WQtNetworkItem();
QGraphicsTextItem *text = new QGraphicsTextItem( module->getName().c_str() );
text->setParentItem( netItem );
text->setDefaultTextColor( Qt::white );
WModule::InputConnectorList cons = module->getInputConnectors();
for ( WModule::InputConnectorList::const_iterator iter = cons.begin(); iter != cons.end(); ++iter )
{
WQtNetworkPort *port = new WQtNetworkPort( iter->get()->getName().c_str(),
iter->get()->isOutputConnector() );
port->setParentItem( netItem );
netItem->addPort( port );
}
WModule::OutputConnectorList outCons = module->getOutputConnectors();
for ( WModule::OutputConnectorList::const_iterator iter = outCons.begin(); iter != outCons.end(); ++iter )
{
WQtNetworkPort *port = new WQtNetworkPort( iter->get()->getName().c_str(),
iter->get()->isOutputConnector() );
port->setParentItem( netItem );
netItem->addPort( port );
}
/*
WQtNetworkPort *port = new WQtNetworkPort( "A", false );
port->setParentItem( netItem );
WQtNetworkPort *iport = new WQtNetworkPort( "B", false );
iport->setParentItem( netItem );
WQtNetworkPort *pport = new WQtNetworkPort( "A", true );
pport->setParentItem( netItem );
WQtNetworkPort *ipport = new WQtNetworkPort( "B", true );
ipport->setParentItem( netItem );
netItem->addPort( port );
netItem->addPort( iport );
netItem->addPort( pport );
netItem->addPort( ipport );
*/
netItem->setFlag( QGraphicsItem::ItemIsMovable );
netItem->setFlag( QGraphicsItem::ItemIsSelectable );
netItem->setTextItem( text );
netItem->fitLook();
m_scene->addItem( netItem );
}
bool WQtNetworkEditor::event( QEvent* event )
{
// a module got associated with the root container -> add it to the list
if ( event->type() == WQT_ASSOC_EVENT )
{
// convert event to assoc event
WModuleAssocEvent* e1 = dynamic_cast< WModuleAssocEvent* >( event ); // NOLINT
if ( e1 )
{
WLogger::getLogger()->addLogMessage( "Inserting module " + e1->getModule()->getName() +
" to network editor.",
"NetworkEditor", LL_DEBUG );
addModule( ( e1->getModule() ).get() );
}
return true;
}
else
{
event->ignore();
return false;
}
}
......@@ -33,6 +33,7 @@
#include <QtGui/QDockWidget>
#include <QtGui/QVBoxLayout>
#include "../../../kernel/modules/data/WMData.h"
#include "WQtNetworkScene.h"
// forward declaration
......@@ -63,6 +64,7 @@ public:
/**
* Simple method to create static test "modules"
*/
void addModule( WModule *module );
void addModule();
protected:
......@@ -72,6 +74,8 @@ protected:
*/
WMainWindow* m_mainWindow;
virtual bool event( QEvent* event );
private:
WQtNetworkScene* m_scene; //!< QGraphicsScene
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment