From e12e7f1b6c5a32373366ffe4172e5ddcd1a05209 Mon Sep 17 00:00:00 2001 From: Eduardo DAVILA Date: Wed, 2 Oct 2013 07:37:29 +0200 Subject: [PATCH] 2149 bbGEditor Bug New Normal Conflict creating inpus and outputs with the same name in complexboxes --- .../bbsKernelEditorGraphic/GBoxModel.cxx | 1 - .../bbtkwxGUIEditorGraphicBBS.cxx | 41 ++++++++++++++----- .../wxVtkSceneManager.cxx | 17 +++++--- 3 files changed, 43 insertions(+), 16 deletions(-) diff --git a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GBoxModel.cxx b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GBoxModel.cxx index 55cdf5e..cb7b911 100644 --- a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GBoxModel.cxx +++ b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GBoxModel.cxx @@ -229,7 +229,6 @@ namespace bbtk //JPR void GBoxModel::addColons(std::string &text) { - printf("EED JPR >>>>>>>>>>>>>>> %s\n",text.c_str() ); std::string character("&&2P&&"); size_t pos; pos = text.find(character); diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx index 9359662..9782025 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx @@ -1094,18 +1094,28 @@ void wxGUIEditorGraphicBBS::OnClickBtnComplexBox(wxCommandEvent& event) } //========================================================================= - +//EED01 void wxGUIEditorGraphicBBS::OnAddComplexBoxInput(wxCommandEvent& event) { wxTextEntryDialog *nameDialog = new wxTextEntryDialog(this, wxT("Name of input port")); - if (nameDialog->ShowModal() == wxID_OK) { + if (nameDialog->ShowModal() == wxID_OK) + { wxString fileName = nameDialog->GetValue(); - if (!fileName.IsEmpty()) { + if (!fileName.IsEmpty()) + { std::string portName = (const char*) (fileName.mb_str()); - _tabsMgr->addActualDiagramComplexInputPort(portName); - } - } + if ( !boxNameExists(portName) ) + { + _tabsMgr->addActualDiagramComplexInputPort(portName); + } else { + wxMessageDialog *dial = new wxMessageDialog(NULL, + wxT("Impossible to create Box. The name already exists. Please provide another name"), + wxT("Change name: name already exists"), wxOK | wxICON_EXCLAMATION | wxSTAY_ON_TOP); + dial->ShowModal(); + } + } // if !fileName + } // if namaDialog } //========================================================================= @@ -1113,13 +1123,24 @@ void wxGUIEditorGraphicBBS::OnAddComplexBoxOutput(wxCommandEvent& event) { wxTextEntryDialog *nameDialog = new wxTextEntryDialog(this, wxT("Name of output port")); - if (nameDialog->ShowModal() == wxID_OK) { + if (nameDialog->ShowModal() == wxID_OK) + { wxString fileName = nameDialog->GetValue(); - if (!fileName.IsEmpty()) { + if (!fileName.IsEmpty()) + { std::string portName = (const char*) (fileName.mb_str()); + if ( !boxNameExists(portName) ) + { _tabsMgr->addActualDiagramComplexOutputPort(portName); - } - } + } else { + wxMessageDialog *dial = new wxMessageDialog(NULL, + wxT("Impossible to create Box. The name already exists. Please provide another name"), + wxT("Change name: name already exists"), wxOK | wxICON_EXCLAMATION | wxSTAY_ON_TOP); + dial->ShowModal(); + } + + } // if !filename + } // namaDialog } //========================================================================= diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx index 3879245..ca8d541 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx @@ -1874,6 +1874,7 @@ void wxVtkSceneManager::getCleanLine(stringstream &inputStream, std::string &lin //========================================================================= void wxVtkSceneManager::loadDiagram(stringstream &inputStream) { + int size; std::string version = ""; std::string line = ""; @@ -2016,6 +2017,7 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream) } + //----------------------- //- COMPLEX OUTPUT PORTS //----------------------- @@ -2145,6 +2147,7 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream) result = strtok(NULL, delims);//name std::string name(result); + getCleanLine(inputStream, line);//ISEXEC:TRUE|FALSE char exec[15]; strcpy(exec, line.c_str()); @@ -2276,6 +2279,7 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream) result = strtok(NULL, delims); std::string nameEndPort(result); + int idCon = configGConnetion(nameStartBox, nameStartPort,nameEndBox, nameEndPort); if (version != "1.0") { @@ -2352,7 +2356,8 @@ GBoxModel* wxVtkSceneManager::findGBox(std::string boxname) for (j = 0; j < (int) lstB.size(); j++) { idB = lstB[j]; bMod = (GBoxModel*) _controllers[idB]->getModel(); - if (_controllers[idB]->getModel()->getBBTKName() == boxname) { + if (_controllers[idB]->getModel()->getBBTKName() == boxname) + { boxModel = bMod; } } // for @@ -2364,7 +2369,8 @@ GBoxModel* wxVtkSceneManager::findGBox(std::string boxname) for (j = 0; j < (int) lstInputs.size(); j++) { idB = lstInputs[j]; bMod = (GBoxModel*) _controllers[idB]->getModel(); - if (_controllers[idB]->getModel()->getBBTKName() == boxname) { + if (_controllers[idB]->getModel()->getBBTKName() == boxname) + { boxModel = bMod; } } // for @@ -2375,7 +2381,8 @@ GBoxModel* wxVtkSceneManager::findGBox(std::string boxname) for (j = 0; j < (int) lstOutputs.size(); j++) { int idB = lstOutputs[j]; bMod = (GBoxModel*) _controllers[idB]->getModel(); - if (_controllers[idB]->getModel()->getBBTKName() == boxname) { + if (_controllers[idB]->getModel()->getBBTKName() == boxname) + { boxModel = bMod; } } // for @@ -2405,7 +2412,7 @@ int wxVtkSceneManager::configGConnetion(std::string nameStartBox, if (boxModel != NULL) { startP = boxModel->getOutputPort(nameStartPort); if(startP == NULL){ - printf("SCP: ERROR in wxVtkSceneManager::configGConnetion start port %s is null. Port name is probably wrong.\n", nameStartPort.c_str()); + printf("SCP: ERROR in wxVtkSceneManager::configGConnetion start port is null. Port name is probably wrong. Start>%s::%s End>%s::%s\n", nameStartBox.c_str(), nameStartPort.c_str(), nameEndBox.c_str(), nameEndPort.c_str() ); } } @@ -2417,7 +2424,7 @@ int wxVtkSceneManager::configGConnetion(std::string nameStartBox, if (boxModel != NULL) { endP = boxModel->getInputPort(nameEndPort); if(endP == NULL){ - printf("SCP: ERROR in wxVtkSceneManager::configGConnetion end port %s is null. Port name is probably wrong\n", nameStartPort.c_str(), nameEndPort.c_str()); + printf("SCP: ERROR in wxVtkSceneManager::configGConnetion end port is null. Port name is probably wrong. Start>%s::%s End>%s::%s \n", nameStartBox.c_str(), nameStartPort.c_str(), nameEndBox.c_str(), nameEndPort.c_str()); } } -- 2.47.1