+//=========================================================================
+
+void wxVtkSceneManager::deleteAllBoxes() {
+ std::map<int, GObjectController*>::iterator it;
+ for (it = _controllers.begin(); it != _controllers.end(); ++it) {
+ GObjectController *cont = it->second;
+ cont->removeFromScene();
+ unregisterController((InteractorStyleMaracas*) cont);
+ }
+ _selectedObjects.clear();
+ _controllers.clear();
+}
+
+//=========================================================================
+
+
+void wxVtkSceneManager::refresh() {
+ _baseView->Refresh();
+}
+//=========================================================================
+
+void wxVtkSceneManager::refreshScene() {
+ _baseView->RefreshView();
+}
+
+//=========================================================================
+
+void wxVtkSceneManager::centerView() {
+ double temp[3];
+ _baseView->GetRenderer()->GetActiveCamera()->GetFocalPoint(temp);
+ _baseView->GetRenderer()->GetActiveCamera()->SetFocalPoint(0, 0, temp[2]);
+ _baseView->GetRenderer()->GetActiveCamera()->GetPosition(temp);
+ _baseView->GetRenderer()->GetActiveCamera()->SetPosition(0, 0, temp[2]);
+}
+
+//=========================================================================
+
+void wxVtkSceneManager::saveDiagram(std::string &content) {
+ char buffer[50];
+
+ content += "CATEGORY:";
+ content += GetCategory();
+ content += "\n";
+
+ content += "DESCRIPTION:";
+ content += GetDescription();
+ content += "\n";
+
+ content += "AUTHOR:";
+ content += GetAuthor();
+ content += "\n";
+
+ //Print info IF COMPLEX BOX
+ content += "COMPLEXBOX:";
+ if (_isComplexBox) {
+ content += "TRUE\n";
+ //ups1
+ content += "COMPLEXBOXNAME:";
+ content += GetCbName();
+ content += "\n";
+
+ content += "PACKAGENAME:";
+ content += GetCbPackageName();
+ content += "\n";
+
+ /* CHANGE TO THE VERSION 1.4 RaC2012 2nd HackFest
+ * External inputs are possible for applications and complex boxes
+ //Print info complex input ports
+ std::vector<int> inputs = getComplexInputPorts();
+ int insize = inputs.size();
+ content += "COMPLEXINPUTS:";
+ sprintf(buffer, "%d", insize);
+ content += buffer;
+ content += "\n";
+
+ for (int i = 0; i < insize; i++) {
+ int id = inputs[i];
+ GObjectController *cont = _controllers[id];
+ cont->getModel()->save(content);
+ }
+ */
+
+ //Print info complex output ports
+ std::vector<int> outputs = getComplexOutputPorts();
+ int outsize = outputs.size();
+ content += "COMPLEXOUTPUTS:";
+ sprintf(buffer, "%d", outsize);
+ content += buffer;
+ content += "\n";
+
+ for (int i = 0; i < outsize; i++) {
+ int id = outputs[i];
+ GObjectController *cont = _controllers[id];
+ cont->getModel()->save(content);
+ }
+ } // _isComplexBox
+ else {
+ content += "FALSE\n";
+ }
+
+ // CHANGE TO THE VERSION 1.4 RaC2012 2nd HackFest
+ // External inputs are possible for applications and complex boxes
+ std::vector<int> inputs = getComplexInputPorts();
+ int insize = inputs.size();
+ content += "COMPLEXINPUTS:";
+ sprintf(buffer, "%d", insize);
+ content += buffer;
+ content += "\n";
+
+ for (int i = 0; i < insize; i++) {
+ int id = inputs[i];
+ GObjectController *cont = _controllers[id];
+ cont->getModel()->save(content);
+ }
+
+ //Print boxes
+ std::vector<int> boxes = getBlackBoxes();
+ int bsize = boxes.size();
+ content += "BOXES:";
+ sprintf(buffer, "%d", bsize);
+ content += buffer;
+ content += "\n";
+
+ for (int i = 0; i < bsize; i++) {
+ int id = boxes[i];
+// std::cout<<"id "<<id<<std::endl;//CFT
+ GObjectController *cont = _controllers[id];
+// std::cout<<"nombre: "<<cont->getStatusText()<<std::endl;//CFT
+// std::cout<<"tipo: "<<cont->getModel()->getBBTKType()<<std::endl;//CFT
+// //boxesDiagram[i] = cont->getModel()->getBBTKType();//CFT
+// std::cout<<"nname: "<<cont->getModel()->getBBTKName()<<std::endl;//CFT
+// std::cout<<"categorie: "<<GetCategory()<<std::endl;//CFT
+// std::cout<<"type: "<<cont->getModel()->getGObjectType()<<std::endl;//CFT
+ cont->getModel()->save(content);
+ }
+
+ //Print connections
+ std::vector<int> connections = getConnections();
+ int csize = connections.size();
+ content += "CONNECTIONS:";
+ sprintf(buffer, "%d", csize);
+ content += buffer;
+ content += "\n";
+
+ for (int i = 0; i < csize; i++) {
+ int id = connections[i];
+ GObjectController *cont = _controllers[id];
+ cont->getModel()->save(content);
+ }
+
+}
+
+//=========================================================================
+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 = "<void>";
+ std::string line = "";
+ char delims[] = ":";
+ char *result = NULL;
+ char poort[POORT_MAX_LINE_SIZE_INTERPRETER];
+
+ getCleanLine(inputStream, line);
+
+ bool start = false;
+ while (!inputStream.eof()) {
+ if (line == "" || line[0] == '#') {
+ line="";
+ getCleanLine(inputStream, line);
+
+ if (line == "# - BBTKGEditor v 1.0 BBG BlackBox Diagram file") {
+ version = line.substr(18, 3);
+ }
+ if (line == "# - BBTKGEditor v 1.1 BBG BlackBox Diagram file") {
+ version = line.substr(18, 3);
+ }
+ if (line == "# - BBTKGEditor v 1.2 BBG BlackBox Diagram file") {
+ version = line.substr(18, 3);
+ }
+ if (line == "# - BBTKGEditor v 1.3 BBG BlackBox Diagram file") {
+ version = line.substr(18, 3);
+ }
+ if (line == "# - BBTKGEditor v 1.4 BBG BlackBox Diagram file") {
+ version = line.substr(18, 3);
+ }
+ } else if (line == "APP_START") {
+ start = true;
+ break;
+ }
+ }
+
+
+ if (start) {
+
+ if ((version != "1.0") && (version != "1.1")) {
+ getCleanLine(inputStream, line);//CATEGORY:<category of the box>
+ char categoryTmp[30];
+ strcpy(categoryTmp, line.c_str());
+ result = strtok(categoryTmp, delims);
+ result = strtok(NULL, delims);
+ SetCategory(result);
+
+ getCleanLine(inputStream, line);//DESCRIPTION:<description of the box>
+ char descriptionTmp[1024];
+ strcpy(descriptionTmp, line.c_str());
+ result = strtok(descriptionTmp, delims);
+ result = strtok(NULL, delims);
+ SetDescription(result);
+
+ getCleanLine(inputStream, line);//AUTHOR:<author>
+ char authorTmp[255];
+ strcpy(authorTmp, line.c_str());
+ result = strtok(authorTmp, delims);
+ result = strtok(NULL, delims);
+ SetAuthor(result);
+ }
+
+ //----------
+ getCleanLine(inputStream, line);//COMPLEX_BOX:TRUE|FALSE
+ char complexTmp[30];
+ strcpy(complexTmp, line.c_str());
+ result = strtok(complexTmp, delims);
+ result = strtok(NULL, delims);
+ std::string isComplexBox(result);
+
+ if (isComplexBox == "TRUE") {
+ _isComplexBox = true;
+
+ if ((version != "1.0") && (version != "1.1")) {
+ getCleanLine(inputStream, line);//COMPLEXNAME:<name of the complex box>
+ char complexboxnameTmp[255];
+ strcpy(complexboxnameTmp, line.c_str());
+ result = strtok(complexboxnameTmp, delims);
+ result = strtok(NULL, delims);
+ SetCbName(result);
+
+ getCleanLine(inputStream, line);//PACKAGENAME:<name of the package of the box>
+ char packagenameTmp[255];
+ strcpy(packagenameTmp, line.c_str());
+ result = strtok(packagenameTmp, delims);
+ result = strtok(NULL, delims);
+ SetCbPackageName(result);
+ }
+
+ if(version < "1.4")
+ {