//=========================================================================
+
void wxVtkSceneManager::disconnectDrop()
{
_baseView->GetWxVTKRenderWindowInteractor()->SetDropTarget(NULL);
}
+
//=========================================================================
+
wxVtkSceneManager::~wxVtkSceneManager()
{
}
+
//=========================================================================
void wxVtkSceneManager::configureBaseView()
iren->SetInteractorStyle(interactorstylebaseview);
interactorstylebaseview->SetwxVtkBaseView(_baseView);
- double posCamera[3];
_baseView->GetRenderer()->GetActiveCamera()->ParallelProjectionOn();
- _baseView->GetRenderer()->GetActiveCamera()->SetPosition(0,0,1000);
- _baseView->GetRenderer()->GetActiveCamera()->GetPosition(posCamera);
- _baseView->GetRenderer()->ResetCamera();
- _baseView->GetRenderer()->ResetCameraClippingRange();
+ _baseView->GetRenderer()->ResetCamera(-100,100,-100,100,900,1000);
-
_baseView->GetRenderer()->SetBackground(0.9,0.9,0.9);
_baseView->GetRenderer()->GradientBackgroundOff();
_baseView->Refresh();
int cantObjects = _objects.size();
cantObjects++;
std::stringstream stream;
- stream << "Box " << cantObjects;
+
+ if(cantObjects<10)
+ {
+ stream << "Box0" << cantObjects;
+ }
+ else
+ {
+ stream << "Box" << cantObjects;
+ }
std::string arraystring = stream.str();
model->setBBTKName(arraystring);
for(itInput = descriptorInMap.begin(); itInput != descriptorInMap.end(); ++itInput)
{
BlackBoxInputDescriptor *desc = itInput->second;
- createGInputPort(desc,model,i);
+ createGInputPort(GINPUTPORT,i,model,desc);
i++;
}
for(itOutput = descriptorOutMap.begin();itOutput != descriptorOutMap.end(); ++itOutput)
{
BlackBoxOutputDescriptor *desc = itOutput->second;
- createGOutputPort(desc,model,i);
+ createGOutputPort(GOUTPUTPORT,i,model,desc);
i++;
}
//Register the controller of the new object
registerController((InteractorStyleMaracas*) controller);
- //Add the object to the objects list (only boxes and connectors)
- _objects.push_back(model);
+ //Add the object to the objects list
+ _objects.push_back(controller);
+
+ int newId = _controllers.size();
+ controller->setId(newId);
+ _controllers[newId] = controller;
}
//=========================================================================
- void wxVtkSceneManager::createGOutputPort(BlackBoxOutputDescriptor *desc,GBlackBoxModel *blackBox, int pos)
+ void wxVtkSceneManager::createGInputPort(int portType, int posinBox,GBlackBoxModel *blackBox, BlackBoxInputDescriptor *desc)
{
- int type = GPORT;
-
- //Create the MVC Objects
- GPortModel *model = (GPortModel*)GObjectsMVCFactory::getInstance()->createGObjectModel(type);
- vtkGObjectView *view = GObjectsMVCFactory::getInstance()->createGObjectView(type);
- GObjectController* controller = GObjectsMVCFactory::getInstance()->createGObjectController(type);
-
- model->registerInBox(blackBox,GOUTPUTPORT, pos);
- blackBox->addOutputPort(model);
-
- model->addObserver(view);
- model->addObserver(this);
+ createGPort(portType,posinBox,blackBox);
+ }
- //Associates the view with the correspondent renderer and the model.
- //(NOTE: Refresh is only made by the view)
- view->setModel(model);
- view->setBaseView(_baseView);
- view->initVtkObjects();
-
- //Associates the controller with the correspondent model and view
- controller->setModelAndView(model,view);
+ //=========================================================================
- //Register the controller of the new object
- registerController((InteractorStyleMaracas*) controller);
+ void wxVtkSceneManager::createGOutputPort(int portType, int posinBox,GBlackBoxModel *blackBox, BlackBoxOutputDescriptor *desc)
+ {
+ createGPort(portType,posinBox,blackBox);
}
//=========================================================================
- void wxVtkSceneManager::createGInputPort(BlackBoxInputDescriptor *desc,GBlackBoxModel *blackBox, int pos)
+ void wxVtkSceneManager::createGPort(int portType, int posInBox,GBlackBoxModel *blackBox)
{
int type = GPORT;
vtkGObjectView *view = GObjectsMVCFactory::getInstance()->createGObjectView(type);
GObjectController* controller = GObjectsMVCFactory::getInstance()->createGObjectController(type);
- model->registerInBox(blackBox,GINPUTPORT,pos);
- blackBox->addInputPort(model);
-
+ model->registerInBox(blackBox,portType, posInBox);
+ blackBox->addOutputPort(model);
+
model->addObserver(view);
model->addObserver(this);
//Associates the controller with the correspondent model and view
controller->setModelAndView(model,view);
+ model->notifyObservers();
+
//Register the controller of the new object
registerController((InteractorStyleMaracas*) controller);
+
+ int newId = _controllers.size();
+ controller->setId(newId);
+ _controllers[newId] = controller;
}
//=========================================================================
manualContourControler* manContourControl = new manualContourControler();
GConnectorView* manViewerContour = new GConnectorView();
manualContourModel* manContourModel = new manualContourModel();
+ manContourModel->SetCloseContour(false);
-
manViewerContour->SetModel( manContourModel );
manViewerContour->SetWxVtkBaseView( _baseView );
manViewerContour->SetRange( 0.5 );
manContourControl->SetModelView( manContourModel , manViewerContour );
manContourControl->Configure();
int i,sizeLstPoints = manContourModel->GetSizeLstPoints();
- //std::cout<<"RaC wxVtkSceneManager::createGConnector "<<this<<" size:"<<sizeLstPoints<<std::endl;
+
for ( i=0; i<sizeLstPoints; i++ )
{
manViewerContour->AddPoint();
}
manContourControl->CreateNewManualContour();
- manViewerContour->RefreshContour();
+
+ manViewerContour->RefreshContour();
+
registerController((InteractorStyleMaracas*) manContourControl);
}
//=========================================================================
- void wxVtkSceneManager::update(int command)
+ void wxVtkSceneManager::update(int idObservable,int command)
{
if(command==INIT_CREATION_CONTOUR)
- {
- for(int i = 0; i<_objects.size();i++)
+ {
+ GObjectController* cont = _controllers[idObservable];
+ if(cont->getGObjectType() == GPORT)
{
- if(_objects[i]->getGObjectType() == GBLACKBOX)
- {
-
- GPortModel* startOutputPort=((GBlackBoxModel*)_objects[i])->getStartOutputPort();
- createGConnector(startOutputPort);
+ GPortController* controller = (GPortController*)cont;
+ vtkGPortView* view = (vtkGPortView*)controller->getView();
- }
- else
+ if(view->getState() == CREATING_CONTOUR)
{
- // The others must not react to events
+ //pre: The port in this state is an output port
+ GPortModel* startOutputPort = (GPortModel*)controller->getModel();
+ createGConnector(startOutputPort);
}
}
+
}
}