Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
syndacate committed May 20, 2016
1 parent 1b37cef commit 4c2980a
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 68 deletions.
21 changes: 15 additions & 6 deletions src/yarpmanager++/src-builder/arrow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,16 @@ void Arrow::updateConnectionFrom(QString from)
}
Application* mainApplication = NULL;
mainApplication = manager->getKnowledgeBase()->getApplication();
manager->getKnowledgeBase()->removeConnectionFromApplication(mainApplication, connection);
Connection updatedCon = connection;
updatedCon.setFrom(from.toLatin1().data());

if(manager->getKnowledgeBase()->updateConnectionOfApplication(mainApplication, connection,updatedCon)){
connection = updatedCon;
}

connection.setFrom(from.toLatin1().data());
// connection.setFrom(from.toLatin1().data());

connection = manager->getKnowledgeBase()->addConnectionToApplication(mainApplication, connection);
// connection = manager->getKnowledgeBase()->addConnectionToApplication(mainApplication, connection);
sigHandler->modified();
}

Expand All @@ -184,11 +189,15 @@ void Arrow::updateConnectionTo(QString to)
}
Application* mainApplication = NULL;
mainApplication = manager->getKnowledgeBase()->getApplication();
manager->getKnowledgeBase()->removeConnectionFromApplication(mainApplication, connection);
Connection updatedCon = connection;
updatedCon.setTo(to.toLatin1().data());

connection.setTo(to.toLatin1().data());
if(manager->getKnowledgeBase()->updateConnectionOfApplication(mainApplication, connection,updatedCon)){
connection = updatedCon;
}

connection = manager->getKnowledgeBase()->addConnectionToApplication(mainApplication, connection);
// connection.setTo(to.toLatin1().data());
// connection = manager->getKnowledgeBase()->addConnectionToApplication(mainApplication, connection);
sigHandler->modified();
}

Expand Down
5 changes: 4 additions & 1 deletion src/yarpmanager++/src-builder/builderitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ void BuilderItem::updateConnections(){
}
}


QList<Arrow *>* BuilderItem::getArrows()
{
return &arrows;
}

void BuilderItem::removeArrow(Arrow *arrow){
int index = arrows.indexOf(arrow);
Expand Down
1 change: 1 addition & 0 deletions src/yarpmanager++/src-builder/builderitem.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class BuilderItem : public QGraphicsObject
void removeArrow(Arrow *arrow);
void removeArrows();
void addArrow(Arrow *arrow);
QList<Arrow *>* getArrows();

bool arrowAlreadyPresent(BuilderItem *endItem);
void updateConnections();
Expand Down
4 changes: 2 additions & 2 deletions src/yarpmanager++/src-builder/builderwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -959,11 +959,11 @@ void BuilderWindow::onModuleSelected(QGraphicsItem *it)
Q_UNUSED(it);
if(editingMode){
if(scene->selectedItems().count() > 1){
propertiesTab->addModules(((ModuleItem*)it)->getInnerModule());
propertiesTab->addModules(((ModuleItem*)it));
return;
}

propertiesTab->showModuleTab(((ModuleItem*)it)->getInnerModule());
propertiesTab->showModuleTab(((ModuleItem*)it));
return;
}

Expand Down
134 changes: 79 additions & 55 deletions src/yarpmanager++/src-builder/propertiestable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void PropertiesTable::showApplicationTab(Application *application)
}


void PropertiesTable::showModuleTab(Module *mod)
void PropertiesTable::showModuleTab(ModuleItem *mod)
{
modules.clear();
disconnect(moduleProperties,SIGNAL(itemChanged(QTreeWidgetItem*,int)),this,SLOT(onModItemChanged(QTreeWidgetItem*,int)));
Expand All @@ -93,15 +93,15 @@ void PropertiesTable::showModuleTab(Module *mod)
moduleProperties->show();
moduleDescription->show();

modName = new QTreeWidgetItem(moduleProperties,QStringList() << "Name" << mod->getName());
modName = new QTreeWidgetItem(moduleProperties,QStringList() << "Name" << mod->getInnerModule()->getName());
modNode = new QTreeWidgetItem(moduleProperties,QStringList() << "Node");
modStdio = new QTreeWidgetItem(moduleProperties,QStringList() << "Stdio" << mod->getStdio());
modWorkDir = new QTreeWidgetItem(moduleProperties,QStringList() << "Workdir" << mod->getWorkDir());
modPrefix = new QTreeWidgetItem(moduleProperties,QStringList() << "Prefix" << mod->getBasePrefix());
modStdio = new QTreeWidgetItem(moduleProperties,QStringList() << "Stdio" << mod->getInnerModule()->getStdio());
modWorkDir = new QTreeWidgetItem(moduleProperties,QStringList() << "Workdir" << mod->getInnerModule()->getWorkDir());
modPrefix = new QTreeWidgetItem(moduleProperties,QStringList() << "Prefix" << mod->getInnerModule()->getBasePrefix());
modDeployer = new QTreeWidgetItem(moduleProperties,QStringList() << "Deployer");
modParams = new QTreeWidgetItem(moduleProperties,QStringList() << "Parameters" << mod->getParam());
modParams = new QTreeWidgetItem(moduleProperties,QStringList() << "Parameters" << mod->getInnerModule()->getParam());

lastPrefix = mod->getBasePrefix();
lastPrefix = mod->getInnerModule()->getBasePrefix();

modStdio->setFlags(modStdio->flags() | Qt::ItemIsEditable);
modWorkDir->setFlags(modWorkDir->flags() | Qt::ItemIsEditable);
Expand Down Expand Up @@ -130,27 +130,27 @@ void PropertiesTable::showModuleTab(Module *mod)
deployerCombo->setEditable(true);
nodeCombo->setEditable(true);

if(compareString(mod->getBroker(),"yarpdev")){
if(compareString(mod->getInnerModule()->getBroker(),"yarpdev")){
deployerCombo->addItem("yarpdev");
}else if(compareString(mod->getBroker(),"icubmoddev")){
}else if(compareString(mod->getInnerModule()->getBroker(),"icubmoddev")){
deployerCombo->addItem("icubmoddev");
}else{
deployerCombo->addItem("local");
deployerCombo->addItem("yarprun");
}

if(strlen(mod->getBroker())){
deployerCombo->setCurrentText(mod->getBroker());
}else if(compareString(mod->getHost(),"localhost")){
if(strlen(mod->getInnerModule()->getBroker())){
deployerCombo->setCurrentText(mod->getInnerModule()->getBroker());
}else if(compareString(mod->getInnerModule()->getHost(),"localhost")){
deployerCombo->setCurrentText("local");
}
if(mod->getNeedDeployer()){
if(mod->getInnerModule()->getNeedDeployer()){
deployerCombo->setEditable(false);
}


nodeCombo->addItem(mod->getHost());
if(QString(mod->getHost()) != "localhost"){
nodeCombo->addItem(mod->getInnerModule()->getHost());
if(QString(mod->getInnerModule()->getHost()) != "localhost"){
nodeCombo->addItem("localhost");
}
ResourcePContainer resources = manager->getKnowledgeBase()->getResources();
Expand All @@ -173,8 +173,8 @@ void PropertiesTable::showModuleTab(Module *mod)

/*****************************/
// Populate paramters
for(int i=0;i<mod->argumentCount();i++){
Argument a = mod->getArgumentAt(i);
for(int i=0;i<mod->getInnerModule()->argumentCount();i++){
Argument a = mod->getInnerModule()->getArgumentAt(i);
QTreeWidgetItem *it = new QTreeWidgetItem(modParams,QStringList() << a.getParam());
QComboBox *paramCombo = new QComboBox();
paramCombo->setEditable(true);
Expand All @@ -194,25 +194,25 @@ void PropertiesTable::showModuleTab(Module *mod)
modParams->setExpanded(true);


QTreeWidgetItem *nameItem = new QTreeWidgetItem(moduleDescription,QStringList() << "Name" << mod->getName());
QTreeWidgetItem *versionItem = new QTreeWidgetItem(moduleDescription,QStringList() << "Version" << mod->getVersion());
QTreeWidgetItem *descriptionItem = new QTreeWidgetItem(moduleDescription,QStringList() << "Description" << mod->getDescription());
QTreeWidgetItem *nameItem = new QTreeWidgetItem(moduleDescription,QStringList() << "Name" << mod->getInnerModule()->getName());
QTreeWidgetItem *versionItem = new QTreeWidgetItem(moduleDescription,QStringList() << "Version" << mod->getInnerModule()->getVersion());
QTreeWidgetItem *descriptionItem = new QTreeWidgetItem(moduleDescription,QStringList() << "Description" << mod->getInnerModule()->getDescription());
QTreeWidgetItem *parametersItem = new QTreeWidgetItem(moduleDescription,QStringList() << "Parameters");
for(int i=0;i<mod->argumentCount();i++){
Argument a = mod->getArgumentAt(i);
for(int i=0;i<mod->getInnerModule()->argumentCount();i++){
Argument a = mod->getInnerModule()->getArgumentAt(i);
QTreeWidgetItem *it = new QTreeWidgetItem(parametersItem,QStringList() << a.getParam() << a.getDescription());

}

QTreeWidgetItem *authorsItem = new QTreeWidgetItem(moduleDescription,QStringList() << "Authors" );
for(int i=0;i<mod->authorCount();i++){
Author a = mod->getAuthorAt(i);
for(int i=0;i<mod->getInnerModule()->authorCount();i++){
Author a = mod->getInnerModule()->getAuthorAt(i);
QTreeWidgetItem *it = new QTreeWidgetItem(authorsItem,QStringList() << a.getName() << a.getEmail());
}

QTreeWidgetItem *inputsItem = new QTreeWidgetItem(moduleDescription,QStringList() << "Inputs" );
for(int i=0;i<mod->inputCount();i++){
InputData a = mod->getInputAt(i);
for(int i=0;i<mod->getInnerModule()->inputCount();i++){
InputData a = mod->getInnerModule()->getInputAt(i);

QTreeWidgetItem *type = new QTreeWidgetItem(inputsItem,QStringList() << "Type" << a.getName());
QTreeWidgetItem *port = new QTreeWidgetItem(type,QStringList() << "Port" << a.getPort());
Expand All @@ -224,8 +224,8 @@ void PropertiesTable::showModuleTab(Module *mod)
}

QTreeWidgetItem *outputsItem = new QTreeWidgetItem(moduleDescription,QStringList() << "Outputs" );
for(int i=0;i<mod->outputCount();i++){
OutputData a = mod->getOutputAt(i); //TODO controllare
for(int i=0;i<mod->getInnerModule()->outputCount();i++){
OutputData a = mod->getInnerModule()->getOutputAt(i); //TODO controllare

QTreeWidgetItem *type = new QTreeWidgetItem(outputsItem,QStringList() << "Type" << a.getName());
QTreeWidgetItem *port = new QTreeWidgetItem(type,QStringList() << "Port" << a.getPort());
Expand Down Expand Up @@ -286,17 +286,17 @@ void PropertiesTable::onModItemChanged(QTreeWidgetItem *it,int col)


if(currentModule){
currentModule->setStdio(modStdio->text(1).toLatin1().data());
currentModule->setWorkDir(modWorkDir->text(1).toLatin1().data());
currentModule->getInnerModule()->setStdio(modStdio->text(1).toLatin1().data());
currentModule->getInnerModule()->setWorkDir(modWorkDir->text(1).toLatin1().data());
if(lastPrefix != modPrefix->text(1)){
currentModule->setBasePrefix(modPrefix->text(1).toLatin1().data());
currentModule->getInnerModule()->setBasePrefix(modPrefix->text(1).toLatin1().data());

string strPrefix;
Application* application = manager->getKnowledgeBase()->getApplication();
if(application){
strPrefix = string(application->getPrefix()) + string(modPrefix->text(1).toLatin1().data());
for(int j=0; j<currentModule->outputCount(); j++){
OutputData *output = &currentModule->getOutputAt(j);
for(int j=0; j<currentModule->getInnerModule()->outputCount(); j++){
OutputData *output = &currentModule->getInnerModule()->getOutputAt(j);

for(int i=0; i<application->connectionCount(); i++){
Connection con = application->getConnectionAt(i);
Expand All @@ -305,40 +305,64 @@ void PropertiesTable::onModItemChanged(QTreeWidgetItem *it,int col)
if(con.getCorOutputData()){
if(con.getCorOutputData() == output){
string strFrom = strPrefix + string(output->getPort());
updatedCon.setFrom(strFrom.c_str());
manager->getKnowledgeBase()->updateConnectionOfApplication(application,
con, updatedCon);
// updatedCon.setFrom(strFrom.c_str());
// manager->getKnowledgeBase()->updateConnectionOfApplication(application,
// con, updatedCon);

for(int k=0;k<currentModule->oPorts.count();k++){
for(int h=0; h<currentModule->oPorts.at(k)->getArrows()->count();h++){
Arrow *a = currentModule->oPorts.at(k)->getArrows()->at(h);
if( a->getTo() == updatedCon.to()){
a->updateConnectionFrom(QString(strFrom.c_str()));

}

}

}
}
}
}
}
}

for(int j=0; j<currentModule->inputCount(); j++){
InputData *input = &currentModule->getInputAt(j);
for(int j=0; j<currentModule->getInnerModule()->inputCount(); j++){
InputData *input = &currentModule->getInnerModule()->getInputAt(j);
for(int i=0; i<application->connectionCount(); i++){
Connection con = application->getConnectionAt(i);
Connection updatedCon = con;
if(con.getCorInputData()){
if(con.getCorInputData() == input){
string strTo = strPrefix + string(input->getPort());
updatedCon.setTo(strTo.c_str());
manager->getKnowledgeBase()->updateConnectionOfApplication(application,
con, updatedCon);
// updatedCon.setTo(strTo.c_str());
// manager->getKnowledgeBase()->updateConnectionOfApplication(application,
// con, updatedCon);

for(int k=0;k<currentModule->iPorts.count();k++){
for(int h=0; h<currentModule->iPorts.at(k)->getArrows()->count();h++){
Arrow *a = currentModule->iPorts.at(k)->getArrows()->at(h);
if(a->getFrom() == updatedCon.from() ){
a->updateConnectionTo(QString(strTo.c_str()));

}

}

}
}
}
}
}
manager->getKnowledgeBase()->setModulePrefix(currentModule, strPrefix.c_str(), false);
manager->getKnowledgeBase()->setModulePrefix(currentModule->getInnerModule(), strPrefix.c_str(), false);
}

}

for(int i=0;i<modules.count();i++){
Module *module = modules.at(i);
if(!strcmp(module->getName(),currentModule->getName())){
module->setStdio(currentModule->getStdio());
module->setWorkDir(currentModule->getWorkDir());
Module *module = modules.at(i)->getInnerModule();
if(!strcmp(module->getName(),currentModule->getInnerModule()->getName())){
module->setStdio(currentModule->getInnerModule()->getStdio());
module->setWorkDir(currentModule->getInnerModule()->getWorkDir());
}
}
modified();
Expand All @@ -360,15 +384,15 @@ void PropertiesTable::onComboChanged(QWidget *combo)
{
if(combo == deployerCombo){
if(currentModule){
currentModule->setBroker(((QComboBox*)combo)->currentText().toLatin1().data());
currentModule->getInnerModule()->setBroker(((QComboBox*)combo)->currentText().toLatin1().data());
}
modified();
return;
}
if(combo == nodeCombo){

if(currentModule){
currentModule->setHost(((QComboBox*)combo)->currentText().toLatin1().data());
currentModule->getInnerModule()->setHost(((QComboBox*)combo)->currentText().toLatin1().data());
}
modified();
return;
Expand All @@ -385,21 +409,21 @@ void PropertiesTable::onComboChanged(QWidget *combo)
}
modParams->setText(1,params);
if(currentModule){
currentModule->setParam(params.toLatin1().data());
currentModule->getInnerModule()->setParam(params.toLatin1().data());
}

for(int i=0;i<modules.count();i++){
Module *module = modules.at(i);
if(!strcmp(module->getName(),currentModule->getName())){
module->setParam(currentModule->getParam());
module->setHost(currentModule->getHost());
module->setBroker(currentModule->getBroker());
Module *module = modules.at(i)->getInnerModule();
if(!strcmp(module->getName(),currentModule->getInnerModule()->getName())){
module->setParam(currentModule->getInnerModule()->getParam());
module->setHost(currentModule->getInnerModule()->getHost());
module->setBroker(currentModule->getInnerModule()->getBroker());
}
}
modified();
}

void PropertiesTable::addModules(Module *mod)
void PropertiesTable::addModules(ModuleItem *mod)
{
modules.append(mod);
}
9 changes: 5 additions & 4 deletions src/yarpmanager++/src-builder/propertiestable.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <yarp/manager/application.h>
#include <yarp/manager/module.h>
#include <yarp/manager/manager.h>
#include "moduleitem.h"


using namespace std;
Expand All @@ -21,13 +22,13 @@ class PropertiesTable : public QWidget
public:
explicit PropertiesTable(Manager *manager, QWidget *parent = 0);
void showApplicationTab(Application *application);
void showModuleTab(Module *it);
void addModules(Module *);
void showModuleTab(ModuleItem *it);
void addModules(ModuleItem *);


private:
Application *currentApplication;
Module *currentModule;
ModuleItem *currentModule;
QTabWidget *propertiesTab;
QTreeWidget *appProperties;
QTreeWidget *moduleProperties;
Expand Down Expand Up @@ -63,7 +64,7 @@ class PropertiesTable : public QWidget

QString lastPrefix;

QList <Module *> modules;
QList <ModuleItem *> modules;


signals:
Expand Down

0 comments on commit 4c2980a

Please sign in to comment.