+ //Connection info
+ GPortModel *start = model->getStartPort();
+ GBoxModel *startBox = start->getParentBox();
+
+ GPortModel *end = model->getEndPort();
+ GBoxModel *endBox = end->getParentBox();
+
+ if (startBox->getGObjectType() == GCOMPLEXINPUTPORT) {
+ complexInputs += "input ";
+ complexInputs += startBox->getBBTKName();
+
+ complexInputs += " ";
+ complexInputs += endBox->getBBTKName();
+ complexInputs += ".";
+ complexInputs += end->getBBTKName();
+
+ complexInputs += " ";
+ complexInputs += "\" \"";
+
+ complexInputs += "\n";
+ } else if (endBox->getGObjectType() == GCOMPLEXOUTPUTPORT) {
+ complexOutputs += "output ";
+ complexOutputs += endBox->getBBTKName();
+
+ complexOutputs += " ";
+ complexOutputs += startBox->getBBTKName();
+ complexOutputs += ".";
+ complexOutputs += start->getBBTKName();
+
+ complexOutputs += " ";
+ complexOutputs += "\" \"";
+
+ complexOutputs += "\n";
+ } else {
+ script += "connect ";
+ script += startBox->getBBTKName();
+ script += ".";
+ script += start->getBBTKName();
+
+ script += " ";
+
+ //End Connection info
+ script += endBox->getBBTKName();
+ script += ".";
+ script += end->getBBTKName();
+
+ script += "\n";
+ }
+ }
+
+ script += "\n";
+ script += "# Complex input ports\n";
+ script += complexInputs;
+
+ script += "\n";
+ script += "# Complex output ports\n";
+ script += complexOutputs;
+
+ script += "\n";
+
+ if((_MessageKind!="-")&&(_MessageLevel!="-"))
+ {
+ script += "message ";
+ script += _MessageKind;
+ script += " ";
+ script += _MessageLevel;
+ script += "\n";
+ }
+
+ for (i = 0; i < (int) execBoxes.size(); i++)
+ {
+ script += "exec ";
+ int id = execBoxes[i];
+ GObjectController *control = _controllers[id];
+ GBlackBoxModel *model = (GBlackBoxModel*) control->getModel();
+
+ script += model->getBBTKName();
+ script += "\n";
+ }
+
+ script += "\n";
+ script += "endefine";
+ script += "\n";
+
+ return script;
+}
+
+//=========================================================================
+
+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 bb[6];
+ _baseView->GetRenderer()->ComputeVisiblePropBounds(bb);
+
+ 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]);
+
+ _baseView->GetRenderer()->ResetCamera();
+ _baseView->GetRenderer()->ResetCameraClippingRange();
+
+/*
+ double tt=_baseView->GetRenderer()->GetNearClippingPlaneTolerance();
+ printf("EED wxVtkSceneManager::centerView() tolerance=%f\n",tt);
+ double cr1,cr2;
+ _baseView->GetRenderer()->GetActiveCamera()->GetClippingRange(cr1,cr2);
+ printf("EED wxVtkSceneManager::centerView() cr1=%f cr2=%f\n",cr1,cr2);
+ _baseView->GetRenderer()->GetActiveCamera()->SetClippingRange(0.01,100000);
+ _baseView->GetRenderer()->GetActiveCamera()->GetClippingRange(cr1,cr2);
+ printf("EED wxVtkSceneManager::centerView() cr1=%f cr2=%f\n",cr1,cr2);
+*/
+
+ _baseView->GetRenderer()->Render();
+}
+
+//=========================================================================
+
+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);