From 30ec99c0060a1f69fe302da398730d7ceaae6be2 Mon Sep 17 00:00:00 2001 From: davila <> Date: Mon, 9 Jul 2012 14:54:06 +0000 Subject: [PATCH] 1497 BUG Read problem in mac/linux with bbg generated in windows --- .../wxTabPanelsManager.cxx | 3 - .../wxVtkSceneManager.cxx | 86 +++++++++++-------- .../bbsWxGUIEditorGraphic/wxVtkSceneManager.h | 4 + 3 files changed, 54 insertions(+), 39 deletions(-) diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.cxx index a3c0af0..6548a8d 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.cxx +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.cxx @@ -60,7 +60,6 @@ namespace bbtk //========================================================================= void wxTabPanelsManager::addNewTab(wxString tabName) { -printf("EED wxTabPanelsManager::addNewTab 0\n"); _lastId++; wxGEditorTabPanel *newPanel = new wxGEditorTabPanel(_notebook,_lastId); @@ -69,8 +68,6 @@ printf("EED wxTabPanelsManager::addNewTab 0\n"); _actual = newPanel; _notebook->AddPage(newPanel, tabName ,true); - -printf("EED wxTabPanelsManager::addNewTab 1\n"); } diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx index b88f527..6c8acf0 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx @@ -1735,21 +1735,35 @@ void wxVtkSceneManager::saveDiagram(std::string &content) { } +//========================================================================= +void wxVtkSceneManager::getCleanLine(stringstream &inputStream, std::string &line) +{ + getline(inputStream, line,'\n'); + int size = line.length(); + if ( line[ size-1 ]==13 ) + { + line.erase(size-1,1); + } +} + //========================================================================= -void wxVtkSceneManager::loadDiagram(stringstream &inputStream) { - +void wxVtkSceneManager::loadDiagram(stringstream &inputStream) +{ + int size; std::string version = ""; std::string line = ""; char delims[] = ":"; char *result = NULL; - getline(inputStream, line); + getCleanLine(inputStream, line); bool start = false; while (!inputStream.eof()) { if (line == "" || line[0] == '#') { - getline(inputStream, line); + line=""; + getCleanLine(inputStream, line); + if (line == "# - BBTKGEditor v 1.0 BBG BlackBox Diagram file") { version = line.substr(18, 3); } @@ -1768,26 +1782,25 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream) { } } - printf("EED wxVtkSceneManager::loadDiagram version=%s\n", version.c_str()); if (start) { if ((version != "1.0") && (version != "1.1")) { - getline(inputStream, line);//CATEGORY: + getCleanLine(inputStream, line);//CATEGORY: char categoryTmp[30]; strcpy(categoryTmp, line.c_str()); result = strtok(categoryTmp, delims); result = strtok(NULL, delims); SetCategory(result); - getline(inputStream, line);//DESCRIPTION: + getCleanLine(inputStream, line);//DESCRIPTION: char descriptionTmp[1024]; strcpy(descriptionTmp, line.c_str()); result = strtok(descriptionTmp, delims); result = strtok(NULL, delims); SetDescription(result); - getline(inputStream, line);//AUTHOR: + getCleanLine(inputStream, line);//AUTHOR: char authorTmp[255]; strcpy(authorTmp, line.c_str()); result = strtok(authorTmp, delims); @@ -1796,7 +1809,7 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream) { } //---------- - getline(inputStream, line);//COMPLEX_BOX:TRUE|FALSE + getCleanLine(inputStream, line);//COMPLEX_BOX:TRUE|FALSE char complexTmp[30]; strcpy(complexTmp, line.c_str()); result = strtok(complexTmp, delims); @@ -1807,14 +1820,14 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream) { _isComplexBox = true; if ((version != "1.0") && (version != "1.1")) { - getline(inputStream, line);//COMPLEXNAME: + getCleanLine(inputStream, line);//COMPLEXNAME: char complexboxnameTmp[255]; strcpy(complexboxnameTmp, line.c_str()); result = strtok(complexboxnameTmp, delims); result = strtok(NULL, delims); SetCbName(result); - getline(inputStream, line);//PACKAGENAME: + getCleanLine(inputStream, line);//PACKAGENAME: char packagenameTmp[255]; strcpy(packagenameTmp, line.c_str()); result = strtok(packagenameTmp, delims); @@ -1825,7 +1838,7 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream) { //----------------------- //- COMPLEX INPUT PORTS //----------------------- - getline(inputStream, line);//COMPLEXINPUTS:num + getCleanLine(inputStream, line);//COMPLEXINPUTS:num char inputs[30]; strcpy(inputs, line.c_str()); result = strtok(inputs, delims); @@ -1837,12 +1850,12 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream) { for (int i = 0; i < numInputs; i++) { //---------- - getline(inputStream, line);//COMPLEX_PORT - getline(inputStream, line);//name + getCleanLine(inputStream, line);//COMPLEX_PORT + getCleanLine(inputStream, line);//name std::string inputPortName(line); //---------- - getline(inputStream, line);//xInic:yInic:zInic + getCleanLine(inputStream, line);//xInic:yInic:zInic char coord[80]; strcpy(coord, line.c_str()); result = strtok(coord, delims);//xInic @@ -1865,7 +1878,7 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream) { if (zIn==900) zIn=GPOSITION_Z; } - getline(inputStream, line);//FIN_COMPLEX_PORT + getCleanLine(inputStream, line);//FIN_COMPLEX_PORT configGComBoxInputOutputPort(true, inputPortName, xIn, yIn, zIn); @@ -1876,7 +1889,7 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream) { //- COMPLEX OUTPUT PORTS //----------------------- - getline(inputStream, line);//COMPLEXOUTPUTS:num + getCleanLine(inputStream, line);//COMPLEXOUTPUTS:num char outputs[30]; strcpy(outputs, line.c_str()); result = strtok(outputs, delims); @@ -1888,12 +1901,12 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream) { for (int i = 0; i < numOutputs; i++) { //---------- - getline(inputStream, line);//COMPLEX_PORT - getline(inputStream, line);//name + getCleanLine(inputStream, line);//COMPLEX_PORT + getCleanLine(inputStream, line);//name std::string outputPortName(line); //---------- - getline(inputStream, line);//xInic:yInic:zInic + getCleanLine(inputStream, line);//xInic:yInic:zInic char coord[80]; strcpy(coord, line.c_str()); result = strtok(coord, delims);//xInic @@ -1916,7 +1929,7 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream) { if (zIn==900) zIn=GPOSITION_Z; } - getline(inputStream, line);//FIN_COMPLEX_PORT + getCleanLine(inputStream, line);//FIN_COMPLEX_PORT configGComBoxInputOutputPort(false, outputPortName, xIn, yIn, zIn); @@ -1925,7 +1938,7 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream) { } // complex box //---------- - getline(inputStream, line);//BOXES:num + getCleanLine(inputStream, line);//BOXES:num char boxes[9]; strcpy(boxes, line.c_str()); result = strtok(boxes, delims); @@ -1937,8 +1950,8 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream) { for (int i = 0; i < numBoxes; i++) { //---------- - getline(inputStream, line);//BOX - getline(inputStream, line);//package:type:name + getCleanLine(inputStream, line);//BOX + getCleanLine(inputStream, line);//package:type:name char box[150]; strcpy(box, line.c_str()); result = strtok(box, delims);//package @@ -1948,7 +1961,7 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream) { result = strtok(NULL, delims);//name std::string name(result); - getline(inputStream, line);//ISEXEC:TRUE|FALSE + getCleanLine(inputStream, line);//ISEXEC:TRUE|FALSE char exec[15]; strcpy(exec, line.c_str()); result = strtok(exec, delims);//ISEXEC @@ -1956,7 +1969,7 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream) { std::string isExec(result); //---------- - getline(inputStream, line);//xInic:yInic:zInic + getCleanLine(inputStream, line);//xInic:yInic:zInic char coord[80]; strcpy(coord, line.c_str()); result = strtok(coord, delims);//xInic @@ -1982,7 +1995,7 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream) { //---------- - getline(inputStream, line);//xEnd:yEnd:zEnd + getCleanLine(inputStream, line);//xEnd:yEnd:zEnd strcpy(coord, line.c_str()); result = strtok(coord, delims);//xEnd std::string xEnd(result); @@ -2017,10 +2030,10 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream) { GBlackBoxModel *bbmod = (GBlackBoxModel*) cont->getModel(); //---------- - getline(inputStream, line);//PORT o FIN_BOX + getCleanLine(inputStream, line);//PORT o FIN_BOX std::string port = line.substr(0, 4); while (port == "PORT") { - getline(inputStream, line);//name:value + getCleanLine(inputStream, line);//name:value char poort[150]; strcpy(poort, line.c_str()); result = strtok(poort, delims);//name @@ -2030,7 +2043,7 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream) { bbmod->setValueToInput(name, value); - getline(inputStream, line);//PORT o FIN_BOX + getCleanLine(inputStream, line);//PORT o FIN_BOX port = line.substr(0, 4); } // while @@ -2039,7 +2052,7 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream) { /// CONNECTIONS //---------- - getline(inputStream, line);//CONNECTIONS:num + getCleanLine(inputStream, line);//CONNECTIONS:num char conns[30]; strcpy(conns, line.c_str()); result = strtok(conns, delims); @@ -2048,11 +2061,12 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream) { int numConns; std::istringstream isCons(result); isCons >> numConns; - + + for (int i = 0; i < numConns; i++) { //---------- - getline(inputStream, line);//CONNECTION - getline(inputStream, line);//Startbox.PortName:EndBox.PortName + getCleanLine(inputStream, line);//CONNECTION + getCleanLine(inputStream, line);//Startbox.PortName:EndBox.PortName char connec[200]; strcpy(connec, line.c_str()); @@ -2072,7 +2086,7 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream) { GConnectorController *tempp = (GConnectorController*) _controllers[idCon]; GConnectorModel *conMod = (GConnectorModel*) tempp->getModel(); vtkGConnectorView *conView = (vtkGConnectorView*) tempp->getView(); - getline(inputStream, line); //NumberOfControlPoints:## + getCleanLine(inputStream, line); //NumberOfControlPoints:## strcpy(conns, line.c_str()); result = strtok(conns, delims); result = strtok(NULL, delims); @@ -2082,7 +2096,7 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream) { isCons >> numberOfControlPoints; for (int ii = 0; ii < numberOfControlPoints; ii++) { - getline(inputStream, line); //XX:YY:ZZ + getCleanLine(inputStream, line); //XX:YY:ZZ char connec[200]; strcpy(connec, line.c_str()); diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.h b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.h index 4171311..9203963 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.h +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.h @@ -209,9 +209,13 @@ namespace bbtk std::string GetCategory(); std::string GetDescription(); + void getCleanLine(std::stringstream &inputStream, std::string &line); + // JGRR & CM void printAll( int com, int sta ); + + private: std::string _cbName; -- 2.45.0