int i;
for(i=0;i<_inputs.size();i++)
{
- _inputs[i]->updatePortPosition(i);
+ _inputs[i]->updatePortPosition();
}
//Refresh outputs position
for(i=0;i<_outputs.size();i++)
{
- _outputs[i]->updatePortPosition(i);
+ _outputs[i]->updatePortPosition();
}
}
//=========================================================================
- GPortModel* GBlackBoxModel::getStartOutputPort()
- {
- GPortModel* temp = NULL;
-
- for(int i=0; i<_inputs.size() && temp == NULL;i++)
- {
- if(_outputs[i]->getState() == CREATING_CONTOUR)
- {
- temp = _outputs[i];
- }
- }
-
- return temp;
- }
-
- //=========================================================================
} // EO namespace bbtk
_xFin = 0;
_yFin = 0;
_zFin = 900;
- _state = NOTHING_HAPPENS;
}
//=========================================================================
}
//=========================================================================
- void GObjectModel::setState(int state)
- {
- _state = state;
- }
-
- //=========================================================================
-
- int GObjectModel::getState()
- {
- return _state;
- }
-
- //=========================================================================
-
void GObjectModel::setGObjectType(int gObjectType)
{
_gObjectType = gObjectType;
void getCenter(double& x, double& y, double& z);
virtual void setInicPoint(double& x, double& y, double& z);
virtual void setFinalPoint(double& x, double& y, double& z);
- void setState(int state);
- int getState();
+
virtual void move(double xx,double yy,double zz);
virtual bool isPointInside(double x,double y, double z);
double _yFin;
double _zFin;
- int _state;
int _gObjectType;
std::string _bbtkType;
{
_parentBox = NULL;
_portType=-1;
+ _posInBox=0;
}
//=========================================================================
{
_parentBox = blackBox;
_portType = portType;
+ _posInBox = pos;
- updatePortPosition(pos);
+ updatePortPosition();
}
//=========================================================================
- void GPortModel::updatePortPosition(int pos)
+ void GPortModel::updatePortPosition()
{
double xInic, yInic,zInic,xFin,yFin,zFin;
_parentBox->getInicPoint(xInic,yInic,zInic);
posY = yFin;
}
- //Variable 'pos' starts with value 0 and it represents the position of the port in the box from left to right
- posX = xInic + PORT_WIDTH + pos*2*PORT_WIDTH;
+ //Attribute '_posInBox' starts with value 0 and it represents the position of the port in the box from left to right
+ posX = xInic + PORT_WIDTH + _posInBox*2*PORT_WIDTH;
setInicPoint(posX,posY,posZ);
//Public methods
void registerInBox(GBlackBoxModel *blackBox,int portType, int pos);
- void updatePortPosition(int pos);
+ void updatePortPosition();
int getPortType();
private:
GBlackBoxModel *_parentBox;
int _portType;
+ int _posInBox;
//Private Methods
//=========================================================================
- void Observable::notifyObservers(int command)
+ void Observable::notifyObservers(int idObservable,int command)
{
if(_changed)
{
int i;
for(i=0;i<_observers.size();i++)
{
- _observers[i]->update(command);
+ _observers[i]->update(idObservable,command);
}
_changed=false;
}
bool hasChanged();
- void notifyObservers(int command=REPAINT);
+ void notifyObservers(int idObservable=-1,int command=REPAINT);
void setChanged();
}
//=========================================================================
- void Observer::update(int command) //virtual
+ void Observer::update(int idObservable,int command) //virtual
{
//virtual
}
~Observer();
//Public methods
- virtual void update(int command);
+ virtual void update(int idObservable,int command);
private:
//=========================================================================
+
void wxVtkSceneManager::disconnectDrop()
{
_baseView->GetWxVTKRenderWindowInteractor()->SetDropTarget(NULL);
}
+
//=========================================================================
+
wxVtkSceneManager::~wxVtkSceneManager()
{
}
+
//=========================================================================
void wxVtkSceneManager::configureBaseView()
interactorstylebaseview->SetwxVtkBaseView(_baseView);
_baseView->GetRenderer()->GetActiveCamera()->ParallelProjectionOn();
- _baseView->GetRenderer()->ResetCamera(-100,100,-100,100,900,900);
+ _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:Algo " << 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;
}
//=========================================================================
//=========================================================================
- 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);
}
}
+
}
}
#include "GObjectsMVCFactory.h"
#include "Observer.h"
#include "GPortModel.h"
+#include "vtkGPortView.h"
#include "GConnectorView.h"
//Includes bbtk
void configureBaseView();
void createGBlackBox(int x, int y,std::string packageName, std::string boxName);
- void createGInputPort(BlackBoxInputDescriptor *desc,GBlackBoxModel *blackBox, int pos);
- void createGOutputPort(BlackBoxOutputDescriptor *desc,GBlackBoxModel *blackBox, int pos);
+ void createGPort(int portType, int posinBox,GBlackBoxModel *blackBox);
+ void createGInputPort(int portType, int posinBox,GBlackBoxModel *blackBox, BlackBoxInputDescriptor *desc);
+ void createGOutputPort(int portType, int posinBox,GBlackBoxModel *blackBox, BlackBoxOutputDescriptor *desc);
void createGConnector(GPortModel* startPort);
void registerController(InteractorStyleMaracas *param);
virtual bool OnMouseMove();
- virtual void update(int command);
+ virtual void update(int idObservable,int command);
private:
int _id;
wxVtk3DBaseView *_baseView;
- std::vector<GObjectModel*> _objects;
- std::vector<GObjectModel*> _selectedObjects;
+ std::vector<GObjectController*> _objects;
+ std::map<int,GObjectController*> _controllers;
protected:
_wxVTKiren= _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
_wxVTKiren->GetEventPosition( X , Y );
- int state = _model->getState();
+ int state = _view->getState();
//Evaluate new state
if(!_model->hasChanged() && state == DRAG)
{
if(_view->isPointInside(X,Y))
{
- _model->setState(HIGHLIGHTED);
+ _view->setState(HIGHLIGHTED);
_model->setChanged();
}
}
{
if(!_view->isPointInside(X,Y))
{
- _model->setState(NOTHING_HAPPENS);
+ _view->setState(NOTHING_HAPPENS);
_model->setChanged();
}
}
- _model->notifyObservers();
+ _model->notifyObservers(_id);
+
}
return true;
}
wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
wxVTKiren->GetEventPosition(X,Y);
- int state = _model->getState();
+ int state = _view->getState();
//Evaluate new state
if(!_model->hasChanged() && state==HIGHLIGHTED)
{
_view->isStartDragging(true);
- _model->setState(DRAG);
+ _view->setState(DRAG);
_model->setChanged();
}
if(_view->isPointInside(X,Y))
{
_view->isStartDragging(true);
- _model->setState(DRAG);
+ _view->setState(DRAG);
_model->setChanged();
}
}
- _model->notifyObservers();
+ _model->notifyObservers(_id);
}
return true;
}
wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
wxVTKiren->GetEventPosition(X,Y);
- int state = _model->getState();
+ int state = _view->getState();
//Evaluate new state
if(!_model->hasChanged() && state==CLICKED)
{
- _model->setState(SELECTED);
+ _view->setState(SELECTED);
_model->setChanged();
}
if( !_model->hasChanged() && state == DRAG)
{
- _model->setState(SELECTED);
+ _view->setState(SELECTED);
_model->setChanged();
}
- _model->notifyObservers();
+ _model->notifyObservers(_id);
}
return true;
wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
wxVTKiren->GetEventPosition(X,Y);
- _model->notifyObservers();
+ _model->notifyObservers(_id);
}
return true;
}
wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
wxVTKiren->GetEventPosition(X, Y);
- int state = _model->getState();
+ int state = _view->getState();
//Evaluate new state
if( !_model->hasChanged() && state == SELECTED)
{
- _model->setState(NOTHING_HAPPENS);
+ _view->setState(NOTHING_HAPPENS);
_model->setChanged();
}
- _model->notifyObservers();
+ _model->notifyObservers(_id);
}
return true;
-}
+ }
//=========================================================================
virtual bool OnLeftDClick();
virtual bool OnRightButtonDown();
+
private:
//Attributes
}
//=========================================================================
+
GObjectController::~GObjectController()
{
}
+
//=========================================================================
void GObjectController::setModelAndView(GObjectModel* model, vtkGObjectView* view)
_model = model;
_view = view;
}
- //=========================================================================
-bool GObjectController::OnMouseMove()
-{
-
- /********************** VIRTUAL *************************/
+ //=========================================================================
- if ( _vtkInteractorStyleBaseView!=NULL)
+ bool GObjectController::OnMouseMove()
{
- int X,Y;
- wxVTKRenderWindowInteractor *_wxVTKiren;
- _wxVTKiren= _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
- _wxVTKiren->GetEventPosition( X , Y );
-
- int state = _model->getState();
- //Evaluate new state
- if(!_model->hasChanged() && state == DRAG)
- {
- moveObject(X,Y);
- _model->setChanged();
- }
+ /********************** VIRTUAL *************************/
- if(!_model->hasChanged() && state == NOTHING_HAPPENS)
- {
- if(_view->isPointInside(X,Y))
- {
- _model->setState(HIGHLIGHTED);
- _model->setChanged();
- }
- }
- if(!_model->hasChanged() && state==HIGHLIGHTED)
+ if ( _vtkInteractorStyleBaseView!=NULL)
{
- if(!_view->isPointInside(X,Y))
+ int X,Y;
+ wxVTKRenderWindowInteractor *_wxVTKiren;
+ _wxVTKiren= _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
+ _wxVTKiren->GetEventPosition( X , Y );
+
+ int state = _view->getState();
+
+ //Evaluate new state
+ if(!_model->hasChanged() && state == DRAG)
{
- _model->setState(NOTHING_HAPPENS);
+ moveObject(X,Y);
_model->setChanged();
}
+
+ if(!_model->hasChanged() && state == NOTHING_HAPPENS)
+ {
+ if(_view->isPointInside(X,Y))
+ {
+ _view->setState(HIGHLIGHTED);
+ _model->setChanged();
+ }
+ }
+ if(!_model->hasChanged() && state==HIGHLIGHTED)
+ {
+ if(!_view->isPointInside(X,Y))
+ {
+ _view->setState(NOTHING_HAPPENS);
+ _model->setChanged();
+ }
+ }
+
+ _model->notifyObservers(_id);
+
}
-
- _model->notifyObservers();
- }
- /**/
+ /**/
- return true;
-}
-//=========================================================================
-bool GObjectController::OnLeftButtonDown()
-{
- /********************** VIRTUAL *************************
+ return true;
+ }
+
+ //=========================================================================
- if ( _vtkInteractorStyleBaseView!=NULL )
+ bool GObjectController::OnLeftButtonDown()
{
- int X,Y;
- wxVTKRenderWindowInteractor *wxVTKiren;
- wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
- wxVTKiren->GetEventPosition(X,Y);
-
- int state = _model->getState();
+ /********************** VIRTUAL *************************
- //Evaluate new state
- if(!_model->hasChanged() && state==HIGHLIGHTED)
- {
- _view->isStartDragging(true);
- _model->setState(DRAG);
- _model->setChanged();
- }
-
- if( !_model->hasChanged() && state == SELECTED)
+ if ( _vtkInteractorStyleBaseView!=NULL )
{
- if(_view->isPointInside(X,Y))
+ int X,Y;
+ wxVTKRenderWindowInteractor *wxVTKiren;
+ wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
+ wxVTKiren->GetEventPosition(X,Y);
+
+ int state = _model->getState();
+
+ //Evaluate new state
+ if(!_model->hasChanged() && state==HIGHLIGHTED)
{
_view->isStartDragging(true);
_model->setState(DRAG);
_model->setChanged();
- }
+ }
+
+ if( !_model->hasChanged() && state == SELECTED)
+ {
+ if(_view->isPointInside(X,Y))
+ {
+ _view->isStartDragging(true);
+ _model->setState(DRAG);
+ _model->setChanged();
+ }
+ }
+
+ _model->notifyObservers();
}
-
- _model->notifyObservers();
+
+ */
+
+ return true;
}
- */
+ //=========================================================================
+
+ bool GObjectController::OnLeftButtonUp()
+ {
- return true;
-}
-//=========================================================================
-bool GObjectController::OnLeftButtonUp()
-{
+ /********************** VIRTUAL *************************
+
+ if ( _vtkInteractorStyleBaseView!=NULL )
+ {
+ int X,Y;
+ wxVTKRenderWindowInteractor *wxVTKiren;
+ wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
+ wxVTKiren->GetEventPosition(X,Y);
+
+ int state = _model->getState();
+
+ //Evaluate new state
+ if(!_model->hasChanged() && state==CLICKED)
+ {
+ _model->setState(SELECTED);
+ _model->setChanged();
+ }
+
+ if( !_model->hasChanged() && state == DRAG)
+ {
+ _model->setState(SELECTED);
+ _model->setChanged();
+ }
+
+ _model->notifyObservers();
+
+ }
- /********************** VIRTUAL *************************
+ */
+ return true;
+ }
- if ( _vtkInteractorStyleBaseView!=NULL )
+ //=========================================================================
+
+ bool GObjectController::OnLeftDClick()
{
- int X,Y;
- wxVTKRenderWindowInteractor *wxVTKiren;
- wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
- wxVTKiren->GetEventPosition(X,Y);
+ /********************** VIRTUAL *************************
- int state = _model->getState();
-
- //Evaluate new state
- if(!_model->hasChanged() && state==CLICKED)
+ if ( _vtkInteractorStyleBaseView!=NULL )
{
- _model->setState(SELECTED);
- _model->setChanged();
+ int X,Y;
+ wxVTKRenderWindowInteractor *wxVTKiren;
+ wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
+ wxVTKiren->GetEventPosition(X,Y);
+
+ _model->notifyObservers();
}
- if( !_model->hasChanged() && state == DRAG)
+ */
+ return true;
+ }
+
+ //=========================================================================
+
+ bool GObjectController::OnRightButtonDown()
+ {
+ /********************** VIRTUAL *************************/
+
+ if( _vtkInteractorStyleBaseView!= NULL )
{
- _model->setState(SELECTED);
- _model->setChanged();
+ int X,Y;
+ wxVTKRenderWindowInteractor *wxVTKiren;
+ wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
+ wxVTKiren->GetEventPosition(X, Y);
+
+ int state = _view->getState();
+
+ //Evaluate new state
+ if( !_model->hasChanged() && state == SELECTED)
+ {
+ _view->setState(NOTHING_HAPPENS);
+ _model->setChanged();
+ }
+
+ _model->notifyObservers(_id);
}
+
+ /**/
- _model->notifyObservers();
+ return true;
}
- */
- return true;
-}
-//=========================================================================
-bool GObjectController::OnLeftDClick()
-{
- /********************** VIRTUAL *************************
+ //=========================================================================
- if ( _vtkInteractorStyleBaseView!=NULL )
+ void GObjectController::moveObject(int X,int Y)
{
- int X,Y;
- wxVTKRenderWindowInteractor *wxVTKiren;
- wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
- wxVTKiren->GetEventPosition(X,Y);
-
- _model->notifyObservers();
+ _view->moveObject(X,Y);
}
- */
- return true;
-}
-//=========================================================================
-bool GObjectController::OnRightButtonDown()
-{
- /********************** VIRTUAL *************************/
+ //=========================================================================
- if( _vtkInteractorStyleBaseView!= NULL )
+ int GObjectController::getGObjectType()
{
- int X,Y;
- wxVTKRenderWindowInteractor *wxVTKiren;
- wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
- wxVTKiren->GetEventPosition(X, Y);
-
- int state = _model->getState();
-
- //Evaluate new state
- if( !_model->hasChanged() && state == SELECTED)
- {
- _model->setState(NOTHING_HAPPENS);
- _model->setChanged();
- }
-
- _model->notifyObservers();
+ return _model->getGObjectType();
}
+
+ //=========================================================================
- /**/
+ GObjectModel* GObjectController::getModel()
+ {
+ return _model;
+ }
- return true;
+ //=========================================================================
-}
+ vtkGObjectView* GObjectController::getView()
+ {
+ return _view;
+ }
-//=========================================================================
+ //=========================================================================
-void GObjectController::moveObject(int X,int Y)
-{
- _view->moveObject(X,Y);
-}
+ int GObjectController::getId()
+ {
+ return _id;
+ }
-//=========================================================================
+ //=========================================================================
+
+ void GObjectController::setId(int id)
+ {
+ _id = id;
+ }
+
+ //=========================================================================
} // EO namespace bbtk
//Public methods
void setModelAndView(GObjectModel* model, vtkGObjectView* view);
+ int getGObjectType();
+ GObjectModel* getModel();
+ vtkGObjectView* getView();
+
+ int getId();
+ void setId(int id);
private:
//Protected Attributes
GObjectModel* _model;
vtkGObjectView* _view;
+ int _id;
//Protected Methods
virtual bool OnMouseMove();
wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
wxVTKiren->GetEventPosition(X,Y);
- int state = _model->getState();
+ int state = _view->getState();
int portType = ((GPortModel*)_model)->getPortType();
//Evaluate new state
if(!_model->hasChanged() && state==HIGHLIGHTED && portType==GOUTPUTPORT )
{
- _model->setState(CREATING_CONTOUR);
+ _view->setState(CREATING_CONTOUR);
_model->setChanged();
}
- _model->notifyObservers();
+ _model->notifyObservers(_id);
}
return true;
wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
wxVTKiren->GetEventPosition(X,Y);
- int state = _model->getState();
+ int state = _view->getState();
//Evaluate new state
if(!_model->hasChanged() && state==CREATING_CONTOUR)
{
if(_view->isPointInside(X,Y))
{
+ _view->setState(CREATING_CONTOUR);
_model->setChanged();
- _model->notifyObservers(INIT_CREATION_CONTOUR);
+ _model->notifyObservers(_id,INIT_CREATION_CONTOUR);
}
else
{
- _model->setState(NOTHING_HAPPENS);
+ _view->setState(NOTHING_HAPPENS);
_model->setChanged();
- _model->notifyObservers();
+ _model->notifyObservers(_id);
}
}
}
//=========================================================================
- void vtkGBlackBoxView::update(int command)
+ void vtkGBlackBoxView::update(int idObservable,int command)
{
- _objectActor->GetProperty()->SetColor(BOXCONTOUR_NH_R,BOXCONTOUR_NH_G,BOXCONTOUR_NH_B);
-
- if(_model->getState()==NOTHING_HAPPENS)
- {
- _objectActor->GetProperty()->SetLineWidth(1);
- _objectActor->GetProperty()->SetColor(BOXCONTOUR_NH_R,BOXCONTOUR_NH_G,BOXCONTOUR_NH_B);
- //_nameActor->GetProperty()->SetColor(BOXCONTOUR_NH_R,BOXCONTOUR_NH_G,BOXCONTOUR_NH_B);
- _typeActor->GetProperty()->SetColor(BOXCONTOUR_NH_R,BOXCONTOUR_NH_G,BOXCONTOUR_NH_B);
- }
- else if(_model->getState()==HIGHLIGHTED)
- {
- _objectActor->GetProperty()->SetLineWidth(2);
- _objectActor->GetProperty()->SetColor(BOXCONTOUR_HIGHLIGHTED_R,BOXCONTOUR_HIGHLIGHTED_G,BOXCONTOUR_HIGHLIGHTED_B);
- //_nameActor->GetProperty()->SetColor(BOXCONTOUR_HIGHLIGHTED_R,BOXCONTOUR_HIGHLIGHTED_G,BOXCONTOUR_HIGHLIGHTED_B);
- _typeActor->GetProperty()->SetColor(BOXCONTOUR_HIGHLIGHTED_R,BOXCONTOUR_HIGHLIGHTED_G,BOXCONTOUR_HIGHLIGHTED_B);
- }
- else if(_model->getState()==DRAG)
- {
- _objectActor->GetProperty()->SetLineWidth(1.2);
- _objectActor->GetProperty()->SetColor(BOXCONTOUR_DRAG_R,BOXCONTOUR_DRAG_G,BOXCONTOUR_DRAG_B);
- //_nameActor->GetProperty()->SetColor(BOXCONTOUR_DRAG_R,BOXCONTOUR_DRAG_G,BOXCONTOUR_DRAG_B);
- _typeActor->GetProperty()->SetColor(BOXCONTOUR_DRAG_R,BOXCONTOUR_DRAG_G,BOXCONTOUR_DRAG_B);
- }
- else if(_model->getState()==SELECTED)
- {
- _objectActor->GetProperty()->SetLineWidth(2);
- _objectActor->GetProperty()->SetColor(BOXCONTOUR_SELECTED_R,BOXCONTOUR_SELECTED_G,BOXCONTOUR_SELECTED_B);
- //_nameActor->GetProperty()->SetColor(BOXCONTOUR_SELECTED_R,BOXCONTOUR_SELECTED_G,BOXCONTOUR_SELECTED_B);
- _typeActor->GetProperty()->SetColor(BOXCONTOUR_SELECTED_R,BOXCONTOUR_SELECTED_G,BOXCONTOUR_SELECTED_B);
- }
+ updateColors();
+
double xInic, yInic,zInic,xFin, yFin,zFin;
_model->getInicPoint(xInic,yInic,zInic);
_model->getFinalPoint(xFin, yFin,zFin);
updatePositionTextActors(xInic, yInic,zInic);
//-----------
-
- _baseView->RefreshView();
- _baseView->Refresh();
+ setRefreshWaiting();
}
//=========================================================================
//------------
- /*
- _vectorNameText = vtkVectorText::New();
+ _nameActor = vtkTextActor3D::New();
std::string temp = _model->getBBTKName();
- _vectorNameText->SetText(temp.c_str());
-
- vtkPolyDataMapper* txtMapper = vtkPolyDataMapper::New();
- txtMapper->SetInputConnection( _vectorNameText->GetOutputPort());
- _nameActor = vtkActor::New();
- _nameActor->SetMapper(txtMapper);
- */
-
- _vectorNameText = vtkTextActor3D::New();
- std::string temp = _model->getBBTKName();
- _vectorNameText->SetInput( temp.c_str() );
-
+ _nameActor->GetTextProperty()->SetFontSize(80);
+ _nameActor->GetTextProperty()->BoldOn();
+ _nameActor->SetInput(temp.c_str());
//------------
- _vectorTypeText = vtkVectorText::New();
+ _typeActor = vtkTextActor3D::New();
temp = _model->getBBTKType();
- _vectorTypeText->SetText(temp.c_str());
-
- vtkPolyDataMapper* txtMapper = vtkPolyDataMapper::New();
- txtMapper->SetInputConnection( _vectorTypeText->GetOutputPort());
- _typeActor = vtkActor::New();
- _typeActor->SetMapper(txtMapper);
+ _typeActor->GetTextProperty()->SetFontSize(80);
+ _typeActor->GetTextProperty()->BoldOn();
+ _typeActor->SetInput(temp.c_str());
//------------
updatePositionTextActors( xInic, yInic, zInic);
-
- //_nameActor->GetProperty()->SetColor(BOXCONTOUR_NH_R,BOXCONTOUR_NH_G,BOXCONTOUR_NH_B);
- _vectorNameText->GetTextProperty()->SetColor(BOXCONTOUR_NH_R,BOXCONTOUR_NH_G,BOXCONTOUR_NH_B);
- _vectorNameText->GetTextProperty()->SetFontSize(75);//SetColor(BOXCONTOUR_NH_R,BOXCONTOUR_NH_G,BOXCONTOUR_NH_B);
- _vectorNameText->GetTextProperty()->BoldOn();
- _vectorNameText->SetScale(0.05,0.05,1);
- _typeActor->GetProperty()->SetColor(BOXCONTOUR_NH_R,BOXCONTOUR_NH_G,BOXCONTOUR_NH_B);
-
}
//=========================================================================
void vtkGBlackBoxView::addVtkActors()//virtual
{
- //_baseView->GetRenderer()->AddActor(_nameActor);
-
- _baseView->GetRenderer()->AddActor(_vectorNameText);
+ _baseView->GetRenderer()->AddActor(_nameActor);
_baseView->GetRenderer()->AddActor(_typeActor);
void vtkGBlackBoxView::updatePositionTextActors(double xInic, double yInic, double zInic)
{
- //_nameActor->SetPosition(xInic+4,yInic-5,zInic);
- //_nameActor->SetScale(2,2,1);
- _vectorNameText->SetPosition(xInic+4,yInic-5,zInic);
+ _nameActor->SetPosition(xInic+4,yInic-5,zInic);
+ _nameActor->SetScale(0.04,0.04,1);
_typeActor->SetPosition(xInic+4,yInic-10,zInic);
- _typeActor->SetScale(2,2,1);
+ _typeActor->SetScale(0.04,0.04,1);
+ }
+
+ //=========================================================================
+
+ void vtkGBlackBoxView::updateColors()
+ {
+ _objectActor->GetProperty()->SetColor(BOXCONTOUR_NH_R,BOXCONTOUR_NH_G,BOXCONTOUR_NH_B);
+ _nameActor->GetTextProperty()->SetColor(BOXCONTOUR_NH_R,BOXCONTOUR_NH_G,BOXCONTOUR_NH_B);
+ _typeActor->GetTextProperty()->SetColor(BOXCONTOUR_NH_R,BOXCONTOUR_NH_G,BOXCONTOUR_NH_B);
+
+ if(_state==NOTHING_HAPPENS)
+ {
+ _objectActor->GetProperty()->SetLineWidth(1);
+ _objectActor->GetProperty()->SetColor(BOXCONTOUR_NH_R,BOXCONTOUR_NH_G,BOXCONTOUR_NH_B);
+ _nameActor->GetTextProperty()->SetColor(BOXCONTOUR_NH_R,BOXCONTOUR_NH_G,BOXCONTOUR_NH_B);
+ _typeActor->GetTextProperty()->SetColor(BOXCONTOUR_NH_R,BOXCONTOUR_NH_G,BOXCONTOUR_NH_B);
+ }
+ else if(_state==HIGHLIGHTED)
+ {
+ _objectActor->GetProperty()->SetLineWidth(2);
+ _objectActor->GetProperty()->SetColor(BOXCONTOUR_HIGHLIGHTED_R,BOXCONTOUR_HIGHLIGHTED_G,BOXCONTOUR_HIGHLIGHTED_B);
+ _nameActor->GetTextProperty()->SetColor(BOXCONTOUR_HIGHLIGHTED_R,BOXCONTOUR_HIGHLIGHTED_G,BOXCONTOUR_HIGHLIGHTED_B);
+ _typeActor->GetTextProperty()->SetColor(BOXCONTOUR_HIGHLIGHTED_R,BOXCONTOUR_HIGHLIGHTED_G,BOXCONTOUR_HIGHLIGHTED_B);
+ }
+ else if(_state==DRAG)
+ {
+ _objectActor->GetProperty()->SetLineWidth(1.2);
+ _objectActor->GetProperty()->SetColor(BOXCONTOUR_DRAG_R,BOXCONTOUR_DRAG_G,BOXCONTOUR_DRAG_B);
+ _nameActor->GetTextProperty()->SetColor(BOXCONTOUR_DRAG_R,BOXCONTOUR_DRAG_G,BOXCONTOUR_DRAG_B);
+ _typeActor->GetTextProperty()->SetColor(BOXCONTOUR_DRAG_R,BOXCONTOUR_DRAG_G,BOXCONTOUR_DRAG_B);
+ }
+ else if(_state==SELECTED)
+ {
+ _objectActor->GetProperty()->SetLineWidth(2);
+ _objectActor->GetProperty()->SetColor(BOXCONTOUR_SELECTED_R,BOXCONTOUR_SELECTED_G,BOXCONTOUR_SELECTED_B);
+ _nameActor->GetTextProperty()->SetColor(BOXCONTOUR_SELECTED_R,BOXCONTOUR_SELECTED_G,BOXCONTOUR_SELECTED_B);
+ _typeActor->GetTextProperty()->SetColor(BOXCONTOUR_SELECTED_R,BOXCONTOUR_SELECTED_G,BOXCONTOUR_SELECTED_B);
+ }
}
//=========================================================================
//Includes creaMaracasVisu
+#include "vtkInteractorStyleBaseView.h"
+
//Includes vtk
#include "vtkPolyDataMapper.h"
//Private Attributes
vtkPoints *_pts;
- vtkActor* _nameActor;
- vtkActor* _typeActor;
-
- //vtkVectorText* _vectorNameText;
- vtkTextActor3D* _vectorNameText;
-
- vtkVectorText* _vectorTypeText;
+ vtkTextActor3D* _nameActor;
+ vtkTextActor3D* _typeActor;
//Private Methods
void updatePositionTextActors(double xInic, double yInic, double zInic);
//Protected Methods
virtual void addVtkActors();
virtual void createVtkObjects();
- virtual void update(int command);
+ virtual void update(int idObservable,int command);
+ virtual void updateColors();
};
_baseView=NULL;
_objectActor=NULL;
_isStartDragging=false;
+
+ _state = NOTHING_HAPPENS;
}
//=========================================================================
}
//=========================================================================
- void vtkGObjectView::update(int command)//virtual
+ void vtkGObjectView::update(int idObservable,int command)//virtual
{
//virtual
}
//=========================================================================
+ void vtkGObjectView::updateColors() //virtual
+ {
+ //virtual
+ }
+
+ //=========================================================================
+
void vtkGObjectView::addVtkActors()//virtual
{
_baseView->GetRenderer()->AddActor(_objectActor);
//=========================================================================
+ void vtkGObjectView::setState(int state)
+ {
+ _state = state;
+ }
+
+ //=========================================================================
+
+ int vtkGObjectView::getState()
+ {
+ return _state;
+ }
+
+ //=========================================================================
+
+ void vtkGObjectView::setRefreshWaiting()
+ {
+ ((vtkInteractorStyleBaseView*)_baseView->GetInteractorStyleBaseView())->SetRefresh_waiting();
+ }
+
+ //=========================================================================
+
+
} // EO namespace bbtk
// EOF
//Includes creaMaracasVisu
#include <wxVtkBaseView.h>
+#include <vtkInteractorStyleBaseView.h>
//Includes vtk
#include <vtkRenderer.h>
virtual bool isPointInside(int X,int Y);
virtual void moveObject(int X, int Y);
- virtual void update(int command);
+ virtual void update(int idObservable,int command);
void isStartDragging(bool param);
+ void setState(int state);
+ int getState();
+ void setRefreshWaiting();
+
private:
//Private Attributes
wxVtkBaseView *_baseView;
GObjectModel *_model;
vtkActor *_objectActor;
+ int _state;
//Protected Methods
virtual void createVtkObjects();
virtual void addVtkActors();
+ virtual void updateColors();
};
//=========================================================================
vtkGPortView::vtkGPortView()
- {
+ {
}
//=========================================================================
}
//=========================================================================
- void vtkGPortView::update(int command)
+ void vtkGPortView::update(int idObservable,int command)
{
- _objectActor->GetProperty()->SetColor(0.8,0.2,0.5);
- if(_model->getState()==HIGHLIGHTED)
- {
- _objectActor->GetProperty()->SetColor(0.8,0.2,0.5);
- }
- else
- {
- _objectActor->GetProperty()->SetColor(0.3,0.2,0.2);
- }
-
+ updateColors();
+
double xInic, yInic,zInic,xFin, yFin,zFin;
_model->getInicPoint(xInic,yInic,zInic);
_pts->SetPoint(1, xInic, yFin, zInic );
_pts->SetPoint(2, xFin, yFin, zFin );
_pts->SetPoint(3, xFin, yInic, zFin );
-
- //_baseView->GetRenderer()->Render();
- //_baseView->GetRenWin()->Render();
-
+
+ setRefreshWaiting();
}
//=========================================================================
_bboxMapper->SetInput(_pd);
_objectActor->SetMapper(_bboxMapper);
+ updateColors();
+
+
+ }
+
+ //=========================================================================
+
+ void vtkGPortView::updateColors()
+ {
_objectActor->GetProperty()->SetColor(BOXCONTOUR_NH_R,BOXCONTOUR_NH_G,BOXCONTOUR_NH_B);
+ if(_state==HIGHLIGHTED)
+ {
+ _objectActor->GetProperty()->SetColor(0.8,0.2,0.5);
+ }
+ else
+ {
+ _objectActor->GetProperty()->SetColor(0.3,0.2,0.2);
+ }
}
//=========================================================================
#include "vtkGObjectView.h"
//Includes creaMaracasVisu
+#include "vtkInteractorStyleBaseView.h"
//Includes vtk
vtkGPortView();
~vtkGPortView();
- //Public methods
+ //Public methods
+ virtual void update(int idObservable,int command);
private:
//Protected Methods
virtual void createVtkObjects();
- virtual void update(int command);
+ virtual void updateColors();
};