_baseView->GetWxVTKRenderWindowInteractor()->SetDropTarget(parent);
registerController(this);
-
configureBaseView();
- /*//JUST TO TEST
+ ///// ******* TO ERASE *******
+ //JUST TO TEST
+ //
vtkConeSource *cone = vtkConeSource::New();
cone->SetResolution(10);
act->SetMapper(map);
- /////////////////////
-
-
vtkPoints *_pts = vtkPoints::New();
_pts->SetNumberOfPoints(4);
_pointVtkActor->SetMapper(_bboxMapper);
getRenderer()->AddActor(_pointVtkActor);
-
-*/
+ // ******* TO ERASE *******
/////////////////////
-
- //getRenderer()->AddActor(act);
-
- //getRenderer()->Render();
-
-
+
}
}
_baseView->SetInteractorStyleBaseView(interactorstylebaseview);
+ // Important to activate the 2D interaction system
wxVTKRenderWindowInteractor *iren = _baseView->GetWxVTKRenderWindowInteractor();
interactorstylebaseview->SetInteractor ( iren );
iren->SetInteractorStyle(interactorstylebaseview);
interactorstylebaseview->SetwxVtkBaseView(_baseView);
-
- //_baseView->GetRenderer()->SetActiveCamera(_baseView->GetCamera());
- //_baseView->GetRenderer()->ResetCamera ();
- //_baseView->GetCamera()->SetParallelProjection(true);
_baseView->GetRenderer()->SetBackground(0.9,0.9,0.9);
_baseView->GetRenderer()->GradientBackgroundOff();
_baseView->Refresh();
+
}
//=========================================================================
void wxVtkSceneManager::createGBlackBox(int x, int y, std::string packageName, std::string boxName)
{
+
+ int windowWidth=_baseView->GetRenWin()->GetSize()[0];
+ int windowHeight=_baseView->GetRenWin()->GetSize()[1];
+
int type = GBLACKBOX;
//Create the MVC Objects
+
GBlackBoxModel *model = (GBlackBoxModel*)GObjectsMVCFactory::getInstance()->createGObjectModel(type);
vtkGObjectView *view = GObjectsMVCFactory::getInstance()->createGObjectView(type);
GObjectController* controller = GObjectsMVCFactory::getInstance()->createGObjectController(type);
BlackBoxDescriptor::Pointer descriptor = GObjectsMVCFactory::getInstance()->getBlackBoxDescriptor(packageName, boxName);
//Prepares the initial model
+ //The coordinates obtained are the following. Top-Left:x=0,y=0 Bottom-Right:x=width,y=height
+
double xx = x;
- double yy = _baseView->GetRenWin()->GetSize()[1]-y;
+ double yy = windowHeight-y;
+
+ //z value is not important yet, because it is only used a parallel projection
double zz = 0;
+
_baseView->TransCoordScreenToWorld(xx,yy,zz);
model->setInicPoint(xx,yy,zz);
+
model->addObserver(view);
//Iterate and create the input ports
std::map<std::string, BlackBoxInputDescriptor*> descriptorInMap = descriptor->GetInputDescriptorMap();
std::map<std::string, BlackBoxInputDescriptor*>::iterator itInput;
- //ERASE
- cantTemp=0;
-
for(itInput = descriptorInMap.begin(); itInput != descriptorInMap.end(); ++itInput)
{
BlackBoxInputDescriptor *desc = itInput->second;
createGInputPort(desc,model);
-
- //ERASE
- cantTemp+=2;
}
-
//Iterate and create the output ports
std::map<std::string, BlackBoxOutputDescriptor*> descriptorOutMap = descriptor->GetOutputDescriptorMap();
std::map<std::string, BlackBoxOutputDescriptor*>::iterator itOutput;
- //ERASE
- cantTemp=0;
for(itOutput = descriptorOutMap.begin();itOutput != descriptorOutMap.end(); ++itOutput)
{
BlackBoxOutputDescriptor *desc = itOutput->second;
createGOutputPort(desc,model);
- //ERASE
- cantTemp+=2;
}
//Associates the controller with the correspondent model and view
controller->setModelAndView(model,view);
- //Refresh renderwindow with new objects
- refreshRenderWindow();
+ //Resgiter change to the observers of the actual model
+ model->setChanged();
+ model->notifyObservers();
//Register the controller of the new object
registerController((InteractorStyleMaracas*) controller);
vtkGObjectView *view = GObjectsMVCFactory::getInstance()->createGObjectView(type);
GObjectController* controller = GObjectsMVCFactory::getInstance()->createGObjectController(type);
- model->registerInBox(blackBox);
+ model->registerInBox(blackBox,GOUTPUTPORT);
blackBox->addOutputPort(model);
- //Prepares the initial model
- double xx = 0;
- double yy = 0;
- double zz = 0;
- blackBox->getInicPoint(xx,yy,zz);
-
- xx++;
- yy+=cantTemp;
- model->setInicPoint(xx,yy,zz);
-
//Associates the view with the correspondent renderer and the model.
//(NOTE: Refresh is only made by the view)
view->setModel(model);
vtkGObjectView *view = GObjectsMVCFactory::getInstance()->createGObjectView(type);
GObjectController* controller = GObjectsMVCFactory::getInstance()->createGObjectController(type);
- model->registerInBox(blackBox);
+ model->registerInBox(blackBox,GINPUTPORT);
blackBox->addInputPort(model);
-
- //Prepares the initial model
- double xx = 0;
- double yy = 0;
- double zz = 0;
- blackBox->getInicPoint(xx,yy,zz);
-
- xx--;
- yy+=cantTemp;
- model->setInicPoint(xx,yy,zz);
//Associates the view with the correspondent renderer and the model.
//(NOTE: Refresh is only made by the view)
return _baseView->GetRenWin();
}
//=========================================================================
-
- void wxVtkSceneManager::refreshRenderWindow()
- {
- _baseView->GetRenWin()->Render();
- }
- //=========================================================================
bool wxVtkSceneManager::OnMouseMove()
{
- //cout<<"RaC wxVtkSceneManager::OnMouseMove "<<endl;
return true;
}
//=========================================================================