endPort->getInicPoint(xIport,yIport,zIport);
setFinalPoint(xCenter,yIport,zCenter);
+
+ manualPoint* point = _model->GetManualPoint(_model->GetSizeLstPoints()-1);
+ point->SetPoint(xCenter,yIport,zCenter);
+ cout<<"RaC GConnectorModel::setEndPort size:"<<_model->GetSizeLstPoints()<<endl;
}
//=========================================================================
setFinalPoint(posX,posY,posZ);
- setChanged();
- notifyObservers();
+ //notifyObservers();
}
//=========================================================================
//=========================================================================
Observable::Observable()
{
- _changed=false;
}
//=========================================================================
+
Observable::~Observable()
{
}
- //=========================================================================
-
- bool Observable::hasChanged()
- {
- return _changed;
- }
//=========================================================================
- void Observable::notifyObservers(int idController,int command)
+ void Observable::notifyObservers(int idCaller,int command)
{
- if(_changed)
+
+ int i;
+ for(i=0;i<_observers.size();i++)
{
- int i;
- for(i=0;i<_observers.size();i++)
- {
- _observers[i]->update(idController,command);
- }
- _changed=false;
+ _observers[i]->update(idCaller,command);
}
}
- //=========================================================================
-
- void Observable::setChanged()
- {
- _changed=true;
- }
-
//=========================================================================
void Observable::addObserver(Observer *observer)
//Public methods
void addObserver(Observer *observer);
- bool hasChanged();
-
- void notifyObservers(int idController=-1,int command=REPAINT);
-
- void setChanged();
+ void notifyObservers(int idCaller,int command=REPAINT);
private:
- //Private Attributes
- bool _changed;
-
+ //Private Attributes
std::vector<Observer*> _observers;
//Private Methods
controller->setModelAndView(model,view);
//Resgiter change to the observers of the actual model
- model->setChanged();
- model->notifyObservers();
+ model->notifyObservers(_idManager);
//Register the controller of the new object
registerController((InteractorStyleMaracas*) controller);
//Associates the controller with the correspondent model and view
controller->setModelAndView(model,view);
- model->notifyObservers();
+ model->notifyObservers(_idManager);
//Register the controller of the new object
registerController((InteractorStyleMaracas*) controller);
int type = GCONNECTOR;
manualConnectorContourController* manContourControl = new manualConnectorContourController();
- manualConnectorContourView* manViewerContour = new manualConnectorContourView();
+ manualConnectorContourView* manContourView = new manualConnectorContourView();
manualContourModel* manContourModel = new manualContourModel();
GConnectorController* connectorcontroller = new GConnectorController();
manContourModel->SetCloseContour(false);
connectorModel->setStartPort(startPort);
- manViewerContour->SetModel( manContourModel );
- manViewerContour->SetWxVtkBaseView( _baseView );
- manViewerContour->SetRange( 0.5 );
- manViewerContour->SetZ( 900 );
+ manContourView->SetModel( manContourModel );
+ manContourView->SetWxVtkBaseView( _baseView );
+ manContourView->SetRange( 0.5 );
+ manContourView->SetZ( 900 );
- manViewerContour->SetColorNormalContour(0, 0, 1);
- manViewerContour->SetColorEditContour(0.5, 0.5, 0.5);
- manViewerContour->SetColorSelectContour(1, 0.8, 0);
- manViewerContour->SetWidthLine(1);
+ manContourView->SetColorNormalContour(0, 0, 1);
+ manContourView->SetColorEditContour(0.5, 0.5, 0.5);
+ manContourView->SetColorSelectContour(1, 0.8, 0);
+ manContourView->SetWidthLine(1);
- manContourControl->SetModelView( manContourModel , manViewerContour );
+ manContourControl->SetModelView( manContourModel , manContourView );
manContourControl->CreateNewManualContour();
- manViewerContour->RefreshContour();
+ manContourView->RefreshContour();
double x,y,z;
manContourModel->SetCloseContour(false);
manContourModel->AddPoint(x,y,z);
- manViewerContour->AddPoint();
+ manContourView->AddPoint();
manContourModel->AddPoint(x,y,z);
- manViewerContour->AddPoint();
+ manContourView->AddPoint();
int bak= manContourControl->GetNumberOfPointsManualContour() - 1;
manContourControl->_bakIdPoint=bak;
- manViewerContour->Refresh();
+ manContourView->Refresh();
manContourControl->SetMoving( false );
connectorcontroller->setManualContourController(manContourControl);
connectorModel->setManualContourModel(manContourModel);
- connectorcontroller->setModelAndView(connectorModel,NULL);
+ connectorView->setManualContourView(manContourView);
+ connectorcontroller->setModelAndView(connectorModel,connectorView);
int newId = _controllers.size();
connectorcontroller->setId(newId);
if(command == INIT_CREATION_CONTOUR)
{
GObjectController* cont = _controllers[idController];
- if(cont->getGObjectType() == GPORT)
- {
- GPortModel* startOutputPort = (GPortModel*)cont->getModel();
- createGConnector(startOutputPort);
- }
+ GPortModel* startOutputPort = (GPortModel*)cont->getModel();
+ createGConnector(startOutputPort);
+
// The last one is the controller of the connector
for(int i=0;i<_controllers.size()-1;i++)
{
}
else if(command == FIN_CREATION_CONTOUR && _worldState == CREATING_CONTOUR)
{
+
_worldState = NOTHING_HAPPENS;
int id = _controllers.size()-1;
GObjectController* cont = _controllers[id];
GConnectorModel* modelContour = (GConnectorModel*)cont->getModel();
GObjectController* finPort = _controllers[idController];
- if(cont->getGObjectType() == GPORT)
+ if(finPort->getGObjectType() == GPORT)
{
GPortModel* modelPort = (GPortModel*)finPort->getModel();
modelContour->setEndPort(modelPort);
}
- manualContourControler* manCont = ((GConnectorController*)cont)->getManualContourController();
-
- //manCont->SetCompleteCreation( true );
- //manCont->SetKeyBoardMoving( false );
- //manCont->GetManualContourModel()->SetCloseContour(false);
- //manCont->SetEditable( false );
- //manCont->SetPosibleToMove( false );
- //manCont->SetState(0);
+ manualConnectorContourController* manCont = ((GConnectorController*)cont)->getManualContourController();
+ manualConnectorContourView* connView = (manualConnectorContourView*)manCont->GetManualViewBaseContour();
+ connView->Refresh();
for(int i=0;i<_controllers.size();i++)
{
int state = _view->getState();
//Evaluate new state
- if(!_model->hasChanged() && state == DRAG)
+ if( state == DRAG)
{
moveObject(X,Y);
- _model->setChanged();
}
- if(!_model->hasChanged() && state == NOTHING_HAPPENS)
+ if(state == NOTHING_HAPPENS)
{
if(_view->isPointInside(X,Y))
{
- _view->setState(HIGHLIGHTED);
- _model->setChanged();
+ _view->setState(HIGHLIGHTED);
}
}
- if(!_model->hasChanged() && state==HIGHLIGHTED)
+ if( state==HIGHLIGHTED)
{
if(!_view->isPointInside(X,Y))
{
_view->setState(NOTHING_HAPPENS);
- _model->setChanged();
}
}
int state = _view->getState();
//Evaluate new state
- if(!_model->hasChanged() && state==HIGHLIGHTED)
+ if( state==HIGHLIGHTED)
{
_view->isStartDragging(true);
_view->setState(DRAG);
- _model->setChanged();
}
- if( !_model->hasChanged() && state == SELECTED)
+ if( state == SELECTED)
{
if(_view->isPointInside(X,Y))
{
_view->isStartDragging(true);
_view->setState(DRAG);
- _model->setChanged();
}
}
int state = _view->getState();
//Evaluate new state
- if(!_model->hasChanged() && state==CLICKED)
+ if(state==CLICKED)
{
_view->setState(SELECTED);
- _model->setChanged();
}
- if( !_model->hasChanged() && state == DRAG)
+ if( state == DRAG)
{
_view->setState(SELECTED);
- _model->setChanged();
}
_model->notifyObservers(_id);
int state = _view->getState();
//Evaluate new state
- if( !_model->hasChanged() && state == SELECTED)
+ if( state == SELECTED)
{
_view->setState(NOTHING_HAPPENS);
- _model->setChanged();
}
_model->notifyObservers(_id);
//=========================================================================
- manualContourControler* GConnectorController::getManualContourController()
+ manualConnectorContourController* GConnectorController::getManualContourController()
{
return _controller;
}
//=========================================================================
- void GConnectorController::setManualContourController(manualContourControler* controller)
+ void GConnectorController::setManualContourController(manualConnectorContourController* controller)
{
_controller = controller;
_controller->SetVtkInteractorStyleBaseView(_vtkInteractorStyleBaseView);
//Includes same project
#include "GObjectController.h"
+#include "manualConnectorContourView.h"
+#include "manualConnectorContourController.h"
//Includes creaMaracasVisu
-#include <manualContourControler.h>
//Includes std
#include <iostream>
virtual bool OnMiddleButtonDown();
virtual bool OnMiddleButtonUp();
- manualContourControler* getManualContourController();
- void setManualContourController(manualContourControler* controller);
+ manualConnectorContourController* getManualContourController();
+ void setManualContourController(manualConnectorContourController* controller);
private:
//Attributes
- manualContourControler* _controller;
+ manualConnectorContourController* _controller;
//Private Methods
//=========================================================================
+
GConnectorView::GConnectorView()
{
}
//=========================================================================
+
GConnectorView::~GConnectorView()
{
}
+
//=========================================================================
+
+ void GConnectorView::setManualContourView(manualViewContour *viewContour)
+ {
+ manViewContour = viewContour;
+ }
- void GConnectorView::TransfromCoordViewWorld(double &X, double &Y, double &Z, int type)
+ //=========================================================================
+
+ manualViewContour* GConnectorView::getManualContourView()
{
- //_wxvtkbaseview->TransCoordScreenToWorld(X,Y,Z,type);
+ return manViewContour;
}
} // EO namespace bbtk
#include "vtkGObjectView.h"
//Includes creaMaracasVisu
+#include <manualViewContour.h>
//Includes std
#include <iostream>
GConnectorView();
~GConnectorView();
- //Public methods
- virtual void TransfromCoordViewWorld(double &X, double &Y, double &Z, int type=2);
+ //Public methods
+ void setManualContourView(manualViewContour* viewContour);
+ manualViewContour* getManualContourView();
private:
//Attributes
-
+ manualViewContour* manViewContour;
//Private Methods
int state = _view->getState();
//Evaluate new state
- if(!_model->hasChanged() && state == DRAG)
+ if( state == DRAG)
{
moveObject(X,Y);
- _model->setChanged();
}
- if(!_model->hasChanged() && state == NOTHING_HAPPENS)
+ if( state == NOTHING_HAPPENS)
{
if(_view->isPointInside(X,Y))
{
- _view->setState(HIGHLIGHTED);
- _model->setChanged();
+ _view->setState(HIGHLIGHTED);
}
}
- if(!_model->hasChanged() && state==HIGHLIGHTED)
+ if( state==HIGHLIGHTED)
{
if(!_view->isPointInside(X,Y))
{
_view->setState(NOTHING_HAPPENS);
- _model->setChanged();
}
}
{
_view->isStartDragging(true);
_model->setState(DRAG);
- _model->setChanged();
}
if( !_model->hasChanged() && state == SELECTED)
{
_view->isStartDragging(true);
_model->setState(DRAG);
- _model->setChanged();
}
}
if(!_model->hasChanged() && state==CLICKED)
{
_model->setState(SELECTED);
- _model->setChanged();
}
if( !_model->hasChanged() && state == DRAG)
{
_model->setState(SELECTED);
- _model->setChanged();
}
_model->notifyObservers();
int state = _view->getState();
//Evaluate new state
- if( !_model->hasChanged() && state == SELECTED)
+ if( state == SELECTED)
{
_view->setState(NOTHING_HAPPENS);
- _model->setChanged();
}
_model->notifyObservers(_id);
bool GPortController::OnLeftButtonUp()
{
int state = _view->getState();
- if(state == HIGHLIGHTED && _isLeftClickDown)
+ if(_isLeftClickDown)
{
- _isLeftClickDown=false;
-
- if ( _vtkInteractorStyleBaseView!=NULL )
+ if(state==HIGHLIGHTED)
{
- int X,Y;
- wxVTKRenderWindowInteractor *wxVTKiren;
- wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
- wxVTKiren->GetEventPosition(X,Y);
-
int portType = ((GPortModel*)_model)->getPortType();
//Evaluate new state
if(portType==GOUTPUTPORT)
{
- _model->setChanged();
_model->notifyObservers(_id,INIT_CREATION_CONTOUR);
}
else if (portType==GINPUTPORT)
{
- _model->setChanged();
_model->notifyObservers(_id,FIN_CREATION_CONTOUR);
}
-
}
+ else
+ {
+ _view->setState(NOTHING_HAPPENS);
+ }
+ _isLeftClickDown=false;
}
return true;
//=========================================================================
- void manualConnectorContourView::removeStartAndEnd()
+ void manualConnectorContourView::updateStartAndEnd(double* start , double* end)
{
- _wxvtkbaseview->GetRenderer()->RemoveActor( _lstViewPoints[0]->GetVtkActor() );
+ _manContModel->MovePoint(0,start[0],start[1],start[2]);
+ _manContModel->MovePoint(_manContModel->GetSizeLstPoints()-1,end[0],end[1],end[2]);
- _wxvtkbaseview->GetRenderer()->RemoveActor( _lstViewPoints[_lstViewPoints.size()-1]->GetVtkActor() );
+ Refresh();
}
//=========================================================================
//Public methods
virtual void TransfromCoordViewWorld(double &X, double &Y, double &Z, int type=2);
- void removeStartAndEnd();
+ void updateStartAndEnd(double* start , double* end);
private: