//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.
//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.
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();
}
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();
}
//=========================================================================
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;
model->setBBTKType(bbtkType);
model->setBBTKName(bbtkName);
+ model->setBBTKDescription(bbtkDescription);
model->addObserver(view);
model->addObserver(this);
//=========================================================================
-bool wxVtkSceneManager::OnMouseMove() {
+bool wxVtkSceneManager::OnMouseMove()
+{
int X, Y;
bool okStatusMessage = false;
bool okPortMessage = false;
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;
} // for controllers it
}
}
- if (okStatusMessage == false) {
+ if (okStatusMessage == false)
+ {
updateStatusBar("");
}
- if (okPortMessage == false) {
+ if (okPortMessage == false)
+ {
_textActor->SetScale(0.0001);
_fillObjectActor->SetScale(0.0001);
}
//=========================================================================
-bool wxVtkSceneManager::OnLeftButtonDown() {
-
- if (_worldState == INIT_CREATION_CONTOUR) {
+bool wxVtkSceneManager::OnLeftButtonDown()
+{
+ if (_worldState == INIT_CREATION_CONTOUR)
+ {
bool isOverPort = false;
std::map<int, GObjectController*>::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
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
//=========================================================================
-bool wxVtkSceneManager::OnLeftButtonUp() {
+bool wxVtkSceneManager::OnLeftButtonUp()
+{
if (_worldState == DRAG_OBJECTS) {
_worldState = NOTHING_HAPPENS;
}
//=========================================================================
-void wxVtkSceneManager::CancelConnection() {
- if (_worldState == INIT_CREATION_CONTOUR) {
+void wxVtkSceneManager::CancelConnection()
+{
+ if (_worldState == INIT_CREATION_CONTOUR)
+ {
_worldState = NOTHING_HAPPENS;
//int lastId = _controllers.size()-1;
_controllers.erase(_idConnectionInCreation);
std::map<int, GObjectController*>::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);
//=========================================================================
-bool wxVtkSceneManager::OnChar() {
- char keyCode = _vtkInteractorStyleBaseView->GetInteractor()-> GetKeyCode();
- int ctrlkey = _vtkInteractorStyleBaseView->GetInteractor()->GetControlKey();
+bool wxVtkSceneManager::OnChar()
+{
+ bool ok=false;
+ bool oktmp;
+ char keyCode = _vtkInteractorStyleBaseView->GetInteractor()-> GetKeyCode();
+ int ctrlkey = _vtkInteractorStyleBaseView->GetInteractor()->GetControlKey();
// KeyCode 127 : Delete Key
// KeyCode 8 : Backspace Key
- if (keyCode == 8 || keyCode == 127) {
- if (_selectedObjects.size() > 0) {
- for (int i = 0; i < (int) _selectedObjects.size(); i++) {
+ if (keyCode == 8 || keyCode == 127)
+ {
+ for (int i = 0; i < (int) _selectedObjects.size(); i++)
+ {
int id = _selectedObjects[i];
std::map<int, GObjectController*>::iterator it;
it = _controllers.find(id);
- if (it != _controllers.end()) {
- deleteObject(id);
- }
+ if (it != _controllers.end())
+ {
+ oktmp = deleteObject(id);
+ ok = ok||oktmp;
+ } // if
+ }// for selected objects
+ if (ok) _selectedObjects.clear();
+ _parent->saveTempandUpdate("delete object");
+ }// if keyCode
+
+ /// Duplicate
+#ifdef MACOSX
+ if((keyCode==0) && (ctrlkey==1)) {
+#else
+ ctrlkey+=keyCode;
+ if(ctrlkey==5){
+#endif
+ if(_selectedObjects.size()){
+ std::cout<<"objects to copy :";
+ for(int i=0;i<_selectedObjects.size();i++)
+ {
+ std::cout<<_selectedObjects.at(i)<<" ";
}
- _selectedObjects.clear();
- }
- }
- ctrlkey+=keyCode;
- /// Duplicate
- if(ctrlkey==5){
- if(_selectedObjects.size()){
- std::cout<<"objects to copy :";
- for(int i=0;i<_selectedObjects.size();i++){
- std::cout<<_selectedObjects.at(i)<<" ";
- }
- DuplicateObjects(getSelectedObjects());
- }else{
- std::cout<<"No objects to copy\n";
- }
- }
+ DuplicateObjects(getSelectedObjects());
+ }else{
+ std::cout<<"No objects to copy\n";
+ } // _selectedObjects.size
+ } // ctrlkey 5
return true;
}
//=========================================================================
-void wxVtkSceneManager::deleteObject(int id) {
+bool wxVtkSceneManager::deleteObject(int id)
+{
+ bool result=true;
GObjectController *control = _controllers[id];
std::vector<int> controllersToRemove;
-
if (control->getGObjectType() == GBLACKBOX || control->getGObjectType()
== GCOMPLEXINPUTPORT || control->getGObjectType()
== GCOMPLEXOUTPUTPORT) {
// Add box input controllers to be removed
for (int i = 0; i < (int) inputs.size(); i++) {
- AddControlerToBeRemove(&controllersToRemove,
- inputs[i]->getObjectId());
+ AddControlerToBeRemove(&controllersToRemove, inputs[i]->getObjectId());
if (inputs[i]->isConnected()) {
boxConnected = true;
}
// Add box output controllers to be removed
for (int i = 0; i < (int) outputs.size(); i++) {
- AddControlerToBeRemove(&controllersToRemove,
- outputs[i]->getObjectId());
+ AddControlerToBeRemove(&controllersToRemove, outputs[i]->getObjectId());
if (outputs[i]->isConnected()) {
boxConnected = true;
}
// Add box controller to be removed
AddControlerToBeRemove(&controllersToRemove, bbmod->getObjectId());
} else if (control->getGObjectType() == GCONNECTOR) {
- GConnectorModel *conMod = (GConnectorModel*) control->getModel();
- AddControlerToBeRemove(&controllersToRemove, conMod->getObjectId());
+ GConnectorController *gconnectorcontroler = (GConnectorController*)control;
+ if (gconnectorcontroler->getManualContourController()->IsEditable()==false)
+ {
+ GConnectorModel *conMod = (GConnectorModel*) control->getModel();
+ AddControlerToBeRemove(&controllersToRemove, conMod->getObjectId());
+ } else{
+ gconnectorcontroler->getManualContourController()->OnChar();
+ result = false;
+ }
}
std::map<int, GObjectController*>::iterator it;
_controllers.erase(it);
}//if
}// for
- _parent->saveTempandUpdate("delete object");
+
+
+ return result;
}
//=========================================================================
}
//=========================================================================
-
-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 = "<void>";
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);
}
}
}
- printf("EED wxVtkSceneManager::loadDiagram version=%s\n", version.c_str());
if (start) {
if ((version != "1.0") && (version != "1.1")) {
- getline(inputStream, line);//CATEGORY:<category of the box>
+ 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);
- getline(inputStream, line);//DESCRIPTION:<description of the box>
+ 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);
- getline(inputStream, line);//AUTHOR:<author>
+ getCleanLine(inputStream, line);//AUTHOR:<author>
char authorTmp[255];
strcpy(authorTmp, line.c_str());
result = strtok(authorTmp, delims);
}
//----------
- 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);
_isComplexBox = true;
if ((version != "1.0") && (version != "1.1")) {
- getline(inputStream, line);//COMPLEXNAME:<name of the complex box>
+ 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);
- getline(inputStream, line);//PACKAGENAME:<name of the package of the box>
+ getCleanLine(inputStream, line);//PACKAGENAME:<name of the package of the box>
char packagenameTmp[255];
strcpy(packagenameTmp, line.c_str());
result = strtok(packagenameTmp, delims);
//-----------------------
//- 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);
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
if (zIn==900) zIn=GPOSITION_Z;
}
- getline(inputStream, line);//FIN_COMPLEX_PORT
+ getCleanLine(inputStream, line);//FIN_COMPLEX_PORT
configGComBoxInputOutputPort(true, inputPortName, xIn, yIn, zIn);
//- 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);
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
if (zIn==900) zIn=GPOSITION_Z;
}
- getline(inputStream, line);//FIN_COMPLEX_PORT
+ getCleanLine(inputStream, line);//FIN_COMPLEX_PORT
configGComBoxInputOutputPort(false, outputPortName, xIn, yIn, zIn);
} // complex box
//----------
- getline(inputStream, line);//BOXES:num
+ getCleanLine(inputStream, line);//BOXES:num
char boxes[9];
strcpy(boxes, line.c_str());
result = strtok(boxes, delims);
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
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
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
//----------
- 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);
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
bbmod->setValueToInput(name, value);
- getline(inputStream, line);//PORT o FIN_BOX
+ getCleanLine(inputStream, line);//PORT o FIN_BOX
port = line.substr(0, 4);
} // while
/// CONNECTIONS
//----------
- getline(inputStream, line);//CONNECTIONS:num
+ getCleanLine(inputStream, line);//CONNECTIONS:num
char conns[30];
strcpy(conns, line.c_str());
result = strtok(conns, delims);
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());
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);
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());