#include "wxVtkSceneManager.h"
+ #include <vtkPolygon.h>
+ #include <vtkUnstructuredGrid.h>
+
+
namespace bbtk
{
//=========================================================================
wxVtkSceneManager::wxVtkSceneManager(wxGEditorTabPanel *parent, wxVtk3DBaseView *baseView,int idManager)
{
- _parent = parent;
- _numBoxes=0;
- _idManager=idManager;
- _baseView=baseView;
- _startDragging=false;
- _isComplexBox=false;
+ _parent = parent;
+ _numBoxes = 0;
+ _idManager = idManager;
+ _baseView = baseView;
+ _startDragging = false;
+ _isComplexBox = false;
if( _baseView!=NULL )
{
registerController(this);
}
- _idConnectionInCreation=-1;
- _contLastId=0;
+ _idConnectionInCreation = -1;
+ _contLastId = 0;
}
interactorstylebaseview->SetwxVtkBaseView(_baseView);
_baseView->GetRenderer()->GetActiveCamera()->ParallelProjectionOn();
- _baseView->GetRenderer()->ResetCamera(-100,100,-100,100,900,1000);
+ _baseView->GetRenderer()->ResetCamera(-100,100,-100,100,800,1100);
_baseView->GetRenderer()->SetBackground(0.9,0.9,0.9);
- _baseView->GetRenderer()->GradientBackgroundOff();
+ _baseView->GetRenderer()->GradientBackgroundOn();
_baseView->Refresh();
+
+ // Actos Port_Text
+ _textActor = vtkTextActor3D::New();
+ _textActor->SetPosition( -9999 , -9999 , 900 );
+ _textActor->SetInput( "<void>" );
+ _textActor->GetTextProperty()->SetFontSize(60);
+ _textActor->GetTextProperty()->BoldOn();
+ _textActor->GetTextProperty()->SetColor(PORTTEXT_NH_R,PORTTEXT_NH_G,PORTTEXT_NH_B);
+
+ _baseView->GetRenderer()->AddActor( _textActor );
+
+
+ // Actor Fill_Port_Text
+
+ //------------
+ double xInic = 0;
+ double yInic = 0;
+ double zInic = 900;
+
+ vtkPolygon *aPolygon = vtkPolygon::New();
+ _fillObjectActor = vtkActor::New();
+
+ _pts = vtkPoints::New();
+//ups4 EED Borrame
+
+ double w=100,h=10,b=h/15,t=3;
+ _pts->SetNumberOfPoints(21);
+ _pts->InsertPoint(0, xInic+w*0.33-t/2 , yInic , zInic );
+ _pts->InsertPoint(1, xInic+w*0.33 , yInic-t , zInic );
+ _pts->InsertPoint(2, xInic+w*0.33+t/2 , yInic , zInic );
+ _pts->InsertPoint(3, xInic+w*0.33+t/2 , yInic , zInic );
+ _pts->InsertPoint(4, xInic+w-b*4 , yInic+b*0 , zInic );
+
+ _pts->InsertPoint( 5, xInic+w-b*4 , yInic+b*0 , zInic );
+ _pts->InsertPoint( 6, xInic+w-b*2 , yInic+b*1 , zInic );
+ _pts->InsertPoint( 7, xInic+w-b*1 , yInic+b*2 , zInic );
+ _pts->InsertPoint( 8, xInic+w-b*0 , yInic+b*4 , zInic );
+
+ _pts->InsertPoint( 9, xInic+w-b*0 , yInic+h-b*4 , zInic );
+ _pts->InsertPoint(10, xInic+w-b*1 , yInic+h-b*2 , zInic );
+ _pts->InsertPoint(11, xInic+w-b*2 , yInic+h-b*1 , zInic );
+ _pts->InsertPoint(12, xInic+w-b*4 , yInic+h-b*0 , zInic );
+
+ _pts->InsertPoint(13, xInic+b*4 , yInic+h-b*0 , zInic );
+ _pts->InsertPoint(14, xInic+b*2 , yInic+h-b*1 , zInic );
+ _pts->InsertPoint(15, xInic+b*1 , yInic+h-b*2 , zInic );
+ _pts->InsertPoint(16, xInic+b*0 , yInic+h-b*4 , zInic );
+
+ _pts->InsertPoint(17, xInic+b*0 , yInic+b*4 , zInic );
+ _pts->InsertPoint(18, xInic+b*1 , yInic+b*2 , zInic );
+ _pts->InsertPoint(19, xInic+b*2 , yInic+b*1 , zInic );
+ _pts->InsertPoint(20, xInic+b*4 , yInic+b*0 , zInic );
+
+ aPolygon->GetPointIds()->SetNumberOfIds(21);
+ for (int i=0;i<21; i++)
+ {
+ aPolygon->GetPointIds()->SetId(i, i);
+ }
+
+ vtkUnstructuredGrid *aPolygonGrid = vtkUnstructuredGrid::New();
+ aPolygonGrid->Allocate(1, 1);
+ aPolygonGrid->InsertNextCell(aPolygon->GetCellType(), aPolygon->GetPointIds());
+ aPolygonGrid->SetPoints(_pts);
+ _aPolygonMapper = vtkDataSetMapper::New();
+ _aPolygonMapper->SetInput(aPolygonGrid);
+ _fillObjectActor->SetMapper(_aPolygonMapper);
+ _fillObjectActor->GetProperty()->SetColor(PORTFILL_NH_R,PORTFILL_NH_G,PORTFILL_NH_B);
+ _fillObjectActor->GetProperty()->SetOpacity(0);
+ _aPolygonMapper->Modified();
+
+ _baseView->GetRenderer()->AddActor( _fillObjectActor );
}
//=========================================================================
}
//=========================================================================
-//ups1 eed
void wxVtkSceneManager::configGBlackBox(int idBox, double xIn, double yIn, double zIn, std::string name, bool boxExecutable,double xEn,double yEn,double zEn)
{
GObjectController *cont = _controllers[idBox];
//z value is not important yet, because it is only used a parallel projection
double zz = 900;
-
+printf("EED wxVtkSceneManager::createGBlackBox 900-450\n");
_baseView->TransCoordScreenToWorld(xx,yy,zz);
model->setInicPoint(xx,yy,zz);
//z value is not important yet, because it is only used a parallel projection
double zz = 900;
+printf("EED wxVtkSceneManager::createGComplexBoxInputPort 900-450\n");
_baseView->TransCoordScreenToWorld(xx,yy,zz);
model->setInicPoint(xx,yy,zz);
//Create the MVC Objects
- GComplexBoxPortModel *model = (GComplexBoxPortModel*)GObjectsMVCFactory::getInstance()->createGObjectModel(type);
- vtkGObjectView *view = GObjectsMVCFactory::getInstance()->createGObjectView(type);
- GObjectController* controller = GObjectsMVCFactory::getInstance()->createGObjectController(type);
+ GComplexBoxPortModel *model = (GComplexBoxPortModel*)GObjectsMVCFactory::getInstance()->createGObjectModel(type);
+ vtkGObjectView *view = GObjectsMVCFactory::getInstance()->createGObjectView(type);
+ GObjectController *controller = GObjectsMVCFactory::getInstance()->createGObjectController(type);
//Prepares the initial model
//z value is not important yet, because it is only used a parallel projection
double zz = 900;
+
+printf("EED wxVtkSceneManager::createGComplexBoxOutputPort 900-450\n");
_baseView->TransCoordScreenToWorld(xx,yy,zz);
model->setInicPoint(xx,yy,zz);
model->notifyObservers(_idManager);
- int newId = addObjectController(controller);
+ addObjectController(controller);
return (GPortController*)controller;
}
bool wxVtkSceneManager::OnMouseMove()
{
int X,Y;
+ bool okStatusMessage = false;
+ bool okPortMessage = false;
wxVTKRenderWindowInteractor *wxVTKiren;
wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
wxVTKiren->GetEventPosition(X,Y);
else if(_worldState == NOTHING_HAPPENS || _worldState == INIT_CREATION_CONTOUR)
{
std::map<int, GObjectController*>::iterator it;
-
+ double px, py, pz;
for(it = _controllers.begin(); it != _controllers.end(); ++it)
{
GObjectController *desc = it->second;
- int type = desc->getGObjectType();
- int state = desc->getView()->getState();
+ int type = desc->getGObjectType();
+ int state = desc->getView()->getState();
+ desc->getModel()->getCenter(px,py,pz);
if(state == HIGHLIGHTED){
-
+ okStatusMessage = true;
updateStatusBar(desc->getStatusText());
if(type==GBLACKBOX)
{
GBlackBoxModel *mod = (GBlackBoxModel*)desc->getModel();
_parent->displayBlackBoxInfo(mod->getBBTKPackage(),mod->getBBTKType());
- }
- }
- }
+ } // if GBLACKBOX
+ if(type==GPORT)
+ {
+ // PortText
+ okPortMessage = true;
+ py=py+5;
+ _textActor->SetInput( desc->getStatusText().c_str() );
+ _textActor->SetScale(0.1);
+ _textActor->SetPosition( px-25 ,py+1 , pz+2 );
+
+//ups4 EED Borrame
+ // FillPortText
+ px=px-33;
+ py=py;
+ _fillObjectActor->SetScale(1);
+ _fillObjectActor->GetProperty()->SetOpacity(0.50);
+ _fillObjectActor->SetPosition(px,py,1);
+ _aPolygonMapper->Modified();
+ } // if GPORT
+
+ } // for controllers it
+ }
+ }
+ if (okStatusMessage==false)
+ {
+ updateStatusBar("");
+ }
+
+ if (okPortMessage==false)
+ {
+ _textActor->SetScale(0.0001);
+ _fillObjectActor->SetScale(0.0001);
}
+
return true;
}
if(portmod->getPortType()==GINPUTPORT && portView->getState()==HIGHLIGHTED)
{
isOverPort=true;
- }
- }
- }
+ } // if
+ } // if
+ } // for
if(isOverPort==false)
{
desc->SetActive(true);
desc->getView()->setState(NOTHING_HAPPENS);
desc->getModel()->notifyObservers(_idManager);
- }
- }
- }
+ } // for
+ } // isOverPort
+ } // _worldState
if(_selectedObjects.size()!=0)
{
- _worldState = DRAG_OBJECTS;
- _startDragging = true;
+ _worldState = DRAG_OBJECTS;
+ _startDragging = true;
for (int i = 0; i < (int)_selectedObjects.size(); i++)
{
GObjectController* cont = _controllers[id];
cont->getView()->setState(DRAG);
cont->getModel()->notifyObservers(_idManager);
- }
- }
+ } // for
+ } // _selectedObjects
std::string script = "";
script+="# BBTK GEditor Script\n";
script+="# ----------------------\n";
+ script+="\n";
if(existsExec)
{
script+="include std\n"; // EED
script+=packages[i];
script+="\n";
}
+ script+="\n";
// script+="include std\n"; // JPR
GPortModel* inputPort = inputs[j];
if(inputPort->isValueSet())
{
- script+="set ";
+ script+=" set ";
script+=model->getBBTKName();
script+=".";
script+=inputPort->getBBTKName();
script+="\n";
}
}
+ script+="\n";
}
+ script+="\n";
+
for(i = 0; i<(int)connections.size();i++)
{
script+="connect ";
script+="\n";
}
- for(i = 0; i<execBoxes.size();i++)
+ script+="\n";
+ for(i = 0; i<(int)execBoxes.size();i++)
{
script+="exec ";
int id = execBoxes[i];
script+=packages[i];
script+="\n";
}
+ script+="\n";
// Definition of a complex box
script+="define ";
script+=cbName;
script+="\n";
+ script+="\n";
script+="author \" ";
script+=cbAuthor;
script+="description \" ";
script+=cbDescription;
script+="\"\n";
+ script+="\n";
// Create boxes
- for(i = 0; i<boxes.size();i++)
+ for(i = 0; i<(int)boxes.size();i++)
{
script+="new ";
int id = boxes[i];
GPortModel* inputPort = inputs[j];
if(inputPort->isValueSet())
{
- script+="set ";
+ script+=" set ";
script+=model->getBBTKName();
script+=".";
script+=inputPort->getBBTKName();
script+="\n";
}
}
+ script+="\n";
}
std::string complexInputs="";
std::string complexOutputs="";
+ script+="\n";
for(i = 0; i<(int)connections.size();i++)
{
}
}
+ script+="\n";
+
for(i = 0; i<(int)execBoxes.size();i++)
{
script+="exec ";
getline(inputStream,line);//FIN_COMPLEX_PORT
- int idInputPort = createGComplexBoxInputPort(inputPortName);
- GObjectController *cont = _controllers[idInputPort];
- GBoxModel *cbmod = (GBoxModel*)cont->getModel();
- cbmod->setInicPoint(xIn,yIn,zIn);
- cbmod->notifyObservers(_idManager);
+ configGComBoxInputOutputPort(true, inputPortName,xIn,yIn,zIn);
+
+
} // for input complex box
getline(inputStream,line);//FIN_COMPLEX_PORT
-
- int idOutputPort = createGComplexBoxOutputPort(outputPortName);
- GObjectController *cont = _controllers[idOutputPort];
- GBoxModel *cbmod = (GBoxModel*)cont->getModel();
- cbmod->setInicPoint(xIn,yIn,zIn);
- cbmod->notifyObservers(_idManager);
+ configGComBoxInputOutputPort(false, outputPortName,xIn,yIn,zIn);
+
} // for output complex box
} // complex box
GObjectController *cont = _controllers[idBox];
GBlackBoxModel *bbmod = (GBlackBoxModel*)cont->getModel();
+
-
-//ups2 eed
-// GObjectController *cont = _controllers[idBox];
-// GBlackBoxModel *bbmod = (GBlackBoxModel*)cont->getModel();
-// bbmod->setBBTKName(name);
-// bbmod->setInicPoint(xIn,yIn,zIn);
-// bbmod->setFinalPoint(xEn,yEn,zEn);
-// bbmod->setExecutable(boxExecutable);
-
-
//----------
getline(inputStream,line);//PORT o FIN_BOX
std::string port=line.substr(0,4);
} // while
//EED bbmod->notifyObservers(_idManager);
- } // boxes
+ } // for boxes
/// CONNECTIONS
//----------
result = strtok( NULL, delims );
std::string nameEndPort(result);
- configGConnetion(_isComplexBox, nameStartBox, nameStartPort, nameEndBox, nameEndPort);
-//ups 3 EED Borrame
-/*
- std::vector<int> lstB = getBlackBoxes();
- GPortModel *startP = NULL;
- GPortModel *endP = NULL;
- int j;
- for(j = 0;j<lstB.size();j++)
- {
- int idB = lstB[j];
- GBlackBoxModel *bbMod = (GBlackBoxModel*)_controllers[idB]->getModel();
- if(_controllers[idB]->getModel()->getBBTKName()==nameStartBox)
- {
- startP = bbMod->getOutputPort(nameStartPort);
- }
- else if(_controllers[idB]->getModel()->getBBTKName()==nameEndBox)
- {
- endP = bbMod->getInputPort(nameEndPort);
- }
- } // for
-
- if(_isComplexBox)
- {
- if(startP==NULL)
- {
- std::vector<int> lstInputs = getComplexInputPorts();
- for(j = 0;j<lstInputs.size();j++)
- {
- int idB = lstInputs[j];
- GBoxModel *cbMod = (GBoxModel*)_controllers[idB]->getModel();
- if(_controllers[idB]->getModel()->getBBTKName()==nameStartBox)
- {
- startP = cbMod->getOutputPort(nameStartPort);
- } // if
- } // for
- } // if
-
- if(endP==NULL)
- {
- std::vector<int> lstOutputs = getComplexOutputPorts();
- for(j = 0;j<lstOutputs.size();j++)
- {
- int idB = lstOutputs[j];
- GBoxModel *cbMod = (GBoxModel*)_controllers[idB]->getModel();
- if(_controllers[idB]->getModel()->getBBTKName()==nameEndBox)
- {
- endP = cbMod->getInputPort(nameEndPort);
- } // if
- } // for
- } // if endP
- } // complex box
-
- int idCon = createGConnector(startP);
- _worldState = NOTHING_HAPPENS;
- GConnectorController *tempp = (GConnectorController*)_controllers[idCon];
-
- GConnectorModel *conMod = (GConnectorModel*)tempp->getModel();
- vtkGConnectorView *conView = (vtkGConnectorView*)tempp->getView();
- tempp->endContourCreation();
- conMod->setEndPort(endP);
- conView->updateStartEndPoints();
- */
+ configGConnetion(nameStartBox, nameStartPort, nameEndBox, nameEndPort);
} // for numConns
} // start
}
+ //=========================================================================
+
+
+ //=========================================================================
+ void wxVtkSceneManager::configGComBoxInputOutputPort(bool inputoutput, std::string portName, double xIn, double yIn,double zIn)
+ {
+ int idPort;
+ if (inputoutput==true)
+ {
+ idPort = createGComplexBoxInputPort(portName);
+ } else {
+ idPort = createGComplexBoxOutputPort(portName);
+ }
+ GObjectController *cont = _controllers[idPort];
+ GBoxModel *cbmod = (GBoxModel*)cont->getModel();
+ cbmod->setInicPoint(xIn,yIn,zIn);
+ cbmod->notifyObservers(_idManager);
+ }
//=========================================================================
- GBlackBoxModel* wxVtkSceneManager::findGBox(std::string boxname)
+
+ //=========================================================================
+ GBoxModel* wxVtkSceneManager::findGBox(std::string boxname)
{
- GBlackBoxModel *boxModel = NULL;
- GBlackBoxModel *bbMod;
- std::vector<int> lstB = getBlackBoxes();
- int idB;
int j;
+ int idB;
+ GBoxModel *bMod;
+ GBoxModel *boxModel = NULL;
+ std::vector<int> lstB = getBlackBoxes();
for(j = 0;j<(int)lstB.size();j++)
{
- idB = lstB[j];
- bbMod = (GBlackBoxModel*)_controllers[idB]->getModel();
+ idB = lstB[j];
+ bMod = (GBoxModel*)_controllers[idB]->getModel();
if(_controllers[idB]->getModel()->getBBTKName()==boxname)
- {
- boxModel = bbMod;
+ {
+ boxModel = bMod;
}
} // for
+
+ if((_isComplexBox) && (boxModel==NULL))
+ {
+ std::vector<int> lstInputs = getComplexInputPorts();
+ for(j = 0;j<(int)lstInputs.size();j++)
+ {
+ idB = lstInputs[j];
+ bMod = (GBoxModel*)_controllers[idB]->getModel();
+ if(_controllers[idB]->getModel()->getBBTKName()==boxname)
+ {
+ boxModel = bMod;
+ }
+ } // for
+
+ std::vector<int> lstOutputs = getComplexOutputPorts();
+ for(j = 0;j<(int)lstOutputs.size();j++)
+ {
+ int idB = lstOutputs[j];
+ bMod = (GBoxModel*)_controllers[idB]->getModel();
+ if(_controllers[idB]->getModel()->getBBTKName()==boxname)
+ {
+ boxModel = bMod;
+ }
+ } // for
+
+ } // complex box
+
return boxModel;
}
//=========================================================================
- void wxVtkSceneManager::configGConnetion(bool _isComplexBox,
- std::string nameStartBox, std::string nameStartPort, std::string
+ void wxVtkSceneManager::configGConnetion(std::string nameStartBox, std::string nameStartPort, std::string
nameEndBox, std::string nameEndPort)
{
- GPortModel *startP = findGBox(nameStartBox)->getOutputPort(nameStartPort);
- GPortModel *endP = findGBox(nameEndBox)->getInputPort(nameEndPort);
-
-/*ups5 EED Borrame
- std::vector<int> lstB = getBlackBoxes();
- int j;
- for(j = 0;j<(int)lstB.size();j++)
+ printf("EED wxVtkSceneManager::configGConnetion 1 %s %s %s %s\n", nameStartBox.c_str(), nameStartPort.c_str(), nameEndBox.c_str(), nameEndPort.c_str() );
+
+ GBoxModel *boxModel;
+ GPortModel *startP = NULL;
+ GPortModel *endP = NULL;
+
+ boxModel= findGBox(nameStartBox);
+ if (boxModel!=NULL)
{
- int idB = lstB[j];
- GBlackBoxModel *bbMod = (GBlackBoxModel*)_controllers[idB]->getModel();
- if(_controllers[idB]->getModel()->getBBTKName()==nameStartBox)
- {
- startP = bbMod->getOutputPort(nameStartPort);
- }
- else if(_controllers[idB]->getModel()->getBBTKName()==nameEndBox)
- {
- endP = bbMod->getInputPort(nameEndPort);
- }
- } // for
-*/
- int j;
- if(_isComplexBox)
+ startP = boxModel->getOutputPort(nameStartPort);
+ }
+
+ boxModel= findGBox(nameEndBox);
+ if (boxModel!=NULL)
{
- if(startP==NULL)
- {
- std::vector<int> lstInputs = getComplexInputPorts();
- for(j = 0;j<(int)lstInputs.size();j++)
- {
- int idB = lstInputs[j];
- GBoxModel *cbMod = (GBoxModel*)_controllers[idB]->getModel();
- if(_controllers[idB]->getModel()->getBBTKName()==nameStartBox)
- {
- startP = cbMod->getOutputPort(nameStartPort);
- } // if
- } // for
- } // if
-
- if(endP==NULL)
- {
- std::vector<int> lstOutputs = getComplexOutputPorts();
- for(j = 0;j<(int)lstOutputs.size();j++)
- {
- int idB = lstOutputs[j];
- GBoxModel *cbMod = (GBoxModel*)_controllers[idB]->getModel();
- if(_controllers[idB]->getModel()->getBBTKName()==nameEndBox)
- {
- endP = cbMod->getInputPort(nameEndPort);
- } // if
- } // for
- } // if endP
- } // complex box
+ endP = boxModel->getInputPort(nameEndPort);
+ }
+
- int idCon = createGConnector(startP);
- _worldState = NOTHING_HAPPENS;
+ printf("EED wxVtkSceneManager::configGConnetion 2 %p %p \n", startP, endP );
+
+
+ int idCon = createGConnector(startP);
+ _worldState = NOTHING_HAPPENS;
GConnectorController *tempp = (GConnectorController*)_controllers[idCon];
- GConnectorModel *conMod = (GConnectorModel*)tempp->getModel();
- vtkGConnectorView *conView = (vtkGConnectorView*)tempp->getView();
+ GConnectorModel *conMod = (GConnectorModel*)tempp->getModel();
+ vtkGConnectorView *conView = (vtkGConnectorView*)tempp->getView();
tempp->endContourCreation();
conMod->setEndPort(endP);
conView->updateStartEndPoints();
{
int ID = cont->getId();
mapSelected[ID]=cont;
- }
-
+ }
}
}
return mapSelected;
}
- for(int i = 0 ;i<connections.size();i++)
+ for(int i = 0 ;i<(int)connections.size();i++)
{
int objId = connections[i];
GObjectController *cont = objectsMap[objId];