X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FEditorGraphicBBS%2FbbsWxGUIEditorGraphic%2FwxVtkSceneManager.cxx;h=afaa01b68be3a006d4ae539e6be8285583ec1239;hb=567028f33d052a54225024906cce14dc1558162f;hp=cd6e44337e9cd14b0e0f60463c52b9a53866f7d3;hpb=e67542bad05cebe7467b41564f0207d7e7efef74;p=bbtkGEditor.git diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx index cd6e443..afaa01b 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx @@ -366,7 +366,7 @@ int wxVtkSceneManager::createGComplexBoxInputPort(std::string inputName) { //create the output port GPortController* portController = createGPort(GOUTPUTPORT, inputName, - "ComplexInputPort", 0, model); + "ComplexOutputPortType","ComplexOutputPortDescriopton", 0, model); model->addOutputPort((GPortModel*) portController->getModel()); //Associates the view with the correspondent renderer and the model. @@ -424,7 +424,7 @@ int wxVtkSceneManager::createGComplexBoxOutputPort(std::string outputName) { //create the output port GPortController* portController = createGPort(GINPUTPORT, outputName, - "ComplexInputPort", 0, model); + "ComplexInputPort","ComplexInputPortDescription", 0, model); model->addInputPort((GPortModel*) portController->getModel()); //Associates the view with the correspondent renderer and the model. @@ -448,7 +448,7 @@ int wxVtkSceneManager::createGComplexBoxOutputPort(std::string outputName) { int wxVtkSceneManager::createGInputPort(int portType, int posinBox, GBoxModel *blackBox, BlackBoxInputDescriptor *desc) { GPortController* portController = createGPort(portType, desc->GetName(), - desc->GetTypeName(), posinBox, blackBox); + desc->GetTypeName(), desc->GetDescription(), posinBox, blackBox); blackBox->addInputPort((GPortModel*) portController->getModel()); return portController->getId(); } @@ -458,7 +458,7 @@ int wxVtkSceneManager::createGInputPort(int portType, int posinBox, int wxVtkSceneManager::createGOutputPort(int portType, int posinBox, GBoxModel *blackBox, BlackBoxOutputDescriptor *desc) { GPortController* portController = createGPort(portType, desc->GetName(), - desc->GetTypeName(), posinBox, blackBox); + desc->GetTypeName(),desc->GetDescription(), posinBox, blackBox); blackBox->addOutputPort((GPortModel*) portController->getModel()); return portController->getId(); } @@ -466,7 +466,7 @@ int wxVtkSceneManager::createGOutputPort(int portType, int posinBox, //========================================================================= GPortController* wxVtkSceneManager::createGPort(int portType, - std::string bbtkName, std::string bbtkType, int posInBox, + std::string bbtkName, std::string bbtkType, std::string bbtkDescription, int posInBox, GBoxModel *blackBox) { int type = GPORT; @@ -484,6 +484,7 @@ GPortController* wxVtkSceneManager::createGPort(int portType, model->setBBTKType(bbtkType); model->setBBTKName(bbtkName); + model->setBBTKDescription(bbtkDescription); model->addObserver(view); model->addObserver(this); @@ -754,7 +755,8 @@ void wxVtkSceneManager::update(int idController, int command) { //========================================================================= -bool wxVtkSceneManager::OnMouseMove() { +bool wxVtkSceneManager::OnMouseMove() +{ int X, Y; bool okStatusMessage = false; bool okPortMessage = false; @@ -796,16 +798,18 @@ bool wxVtkSceneManager::OnMouseMove() { desc->getModel()->getCenter(px, py, pz); // JGRR & CM - if ((state == HIGHLIGHTED) || (state == SELECTED_POSSIBLE_CONNECTION )) { + if ((state == HIGHLIGHTED) || (state == SELECTED_POSSIBLE_CONNECTION )) + { // EO JGRR & CM okStatusMessage = true; updateStatusBar(desc->getStatusText()); - if (type == GBLACKBOX) { + if (type == GBLACKBOX) + { GBlackBoxModel *mod = (GBlackBoxModel*) desc->getModel(); - _parent->displayBlackBoxInfo(mod->getBBTKPackage(), - mod->getBBTKType()); + _parent->displayBlackBoxInfo(mod->getBBTKPackage(),mod->getBBTKType()); } // if GBLACKBOX - if (type == GPORT) { + if (type == GPORT) + { // PortText okPortMessage = true; py = py + 5; @@ -815,7 +819,7 @@ bool wxVtkSceneManager::OnMouseMove() { // FillPortText px = px - 33; - py = py; + //py = py; _fillObjectActor->SetScale(1); _fillObjectActor->GetProperty()->SetOpacity(0.50); _fillObjectActor->SetPosition(px, py, 1); @@ -825,11 +829,13 @@ bool wxVtkSceneManager::OnMouseMove() { } // for controllers it } } - if (okStatusMessage == false) { + if (okStatusMessage == false) + { updateStatusBar(""); } - if (okPortMessage == false) { + if (okPortMessage == false) + { _textActor->SetScale(0.0001); _fillObjectActor->SetScale(0.0001); } @@ -838,32 +844,35 @@ bool wxVtkSceneManager::OnMouseMove() { //========================================================================= -bool wxVtkSceneManager::OnLeftButtonDown() { - - if (_worldState == INIT_CREATION_CONTOUR) { +bool wxVtkSceneManager::OnLeftButtonDown() +{ + if (_worldState == INIT_CREATION_CONTOUR) + { bool isOverPort = false; std::map::iterator it; - for (it = _controllers.begin(); it != _controllers.end() && isOverPort - == false; ++it) { + for (it = _controllers.begin(); it != _controllers.end() && isOverPort== false; ++it) + { GObjectController *desc = it->second; - if (desc->getGObjectType() == GPORT) { + if (desc->getGObjectType() == GPORT) + { GPortModel *portmod = (GPortModel*) desc->getModel(); vtkGObjectView *portView = desc->getView(); - if (portmod->getPortType() == GINPUTPORT - && portView->getState() == HIGHLIGHTED) { + if (portmod->getPortType() == GINPUTPORT && portView->getState() == HIGHLIGHTED) + { isOverPort = true; - } // if - // JGRR & CM - if ( portmod->getPortType( ) == GINPUTPORT && portView->getState( ) == SELECTED_POSSIBLE_CONNECTION ) { - isOverPort = true ; - portView->setState( HIGHLIGHTED); - } - // EO JGRR & CM - - } // if + } // if + // JGRR & CM + if ( portmod->getPortType( ) == GINPUTPORT && portView->getState( ) == SELECTED_POSSIBLE_CONNECTION ) { + isOverPort = true ; + portView->setState( HIGHLIGHTED); + } + // EO JGRR & CM + + } // if } // for - if (isOverPort == false) { + if (isOverPort == false) + { CancelConnection(); UnSelectBlackBoxes(); } // isOverPort @@ -880,19 +889,20 @@ bool wxVtkSceneManager::OnLeftButtonDown() { GObjectController *cont = GetGBlackBoxControlerPointedByMouse(); - if (GetGBlackBoxControlerPointedByMouse() != NULL) { + if (cont != NULL) { int state = cont->getView()->getState(); if ((ctrlkey == 0) && (state == HIGHLIGHTED)) { UnSelectBlackBoxes(); } + } else { + UnSelectBlackBoxes(); // EED 12/07/2012 } for (int i = 0; i < (int) _selectedObjects.size(); i++) { int id = _selectedObjects[i]; - GObjectController* cont = _controllers[id]; + GObjectController *cont = _controllers[id]; cont->getView()->setState(DRAG); cont->getModel()->notifyObservers(_idManager); } // for - } // if _selectedObjects.size @@ -901,7 +911,8 @@ bool wxVtkSceneManager::OnLeftButtonDown() { //========================================================================= -bool wxVtkSceneManager::OnLeftButtonUp() { +bool wxVtkSceneManager::OnLeftButtonUp() +{ if (_worldState == DRAG_OBJECTS) { _worldState = NOTHING_HAPPENS; @@ -916,8 +927,10 @@ bool wxVtkSceneManager::OnLeftButtonUp() { } //========================================================================= -void wxVtkSceneManager::CancelConnection() { - if (_worldState == INIT_CREATION_CONTOUR) { +void wxVtkSceneManager::CancelConnection() +{ + if (_worldState == INIT_CREATION_CONTOUR) + { _worldState = NOTHING_HAPPENS; //int lastId = _controllers.size()-1; @@ -928,7 +941,8 @@ void wxVtkSceneManager::CancelConnection() { _controllers.erase(_idConnectionInCreation); std::map::iterator it; - for (it = _controllers.begin(); it != _controllers.end(); ++it) { + for (it = _controllers.begin(); it != _controllers.end(); ++it) + { GObjectController *desc = it->second; desc->SetActive(true); desc->getView()->setState(NOTHING_HAPPENS); @@ -1091,7 +1105,8 @@ bool wxVtkSceneManager::OnChar() #endif if(_selectedObjects.size()){ std::cout<<"objects to copy :"; - for(int i=0;i<_selectedObjects.size();i++){ + for(int i=0;i<_selectedObjects.size();i++) + { std::cout<<_selectedObjects.at(i)<<" "; } DuplicateObjects(getSelectedObjects()); @@ -1735,20 +1750,36 @@ void wxVtkSceneManager::saveDiagram(std::string &content) { } //========================================================================= - -void wxVtkSceneManager::loadDiagram(stringstream &inputStream) { - +void wxVtkSceneManager::getCleanLine(stringstream &inputStream, std::string &line) +{ + getline(inputStream, line,'\n'); + int size = line.length(); + if (size>0) + { + if ( line[ size-1 ]==13 ) + { + line.erase(size-1,1); + } // if line + } // if size +} + +//========================================================================= +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); } @@ -1767,26 +1798,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); @@ -1795,7 +1825,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); @@ -1806,14 +1836,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); @@ -1824,7 +1854,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); @@ -1836,12 +1866,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 @@ -1864,7 +1894,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); @@ -1875,7 +1905,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); @@ -1887,12 +1917,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 @@ -1915,7 +1945,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); @@ -1924,7 +1954,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); @@ -1936,8 +1966,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 @@ -1947,7 +1977,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 @@ -1955,7 +1985,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 @@ -1981,7 +2011,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); @@ -2016,10 +2046,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 @@ -2029,7 +2059,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 @@ -2038,7 +2068,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); @@ -2047,11 +2077,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()); @@ -2071,7 +2102,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); @@ -2081,7 +2112,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());