int state = _view->getState();
//Evaluate new state
- if(!_model->hasChanged() && 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();
}
}
bool GBlackBoxController::OnLeftButtonDown()
{
-
- if ( _vtkInteractorStyleBaseView!=NULL )
- {
- int X,Y;
- wxVTKRenderWindowInteractor *wxVTKiren;
- wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
- wxVTKiren->GetEventPosition(X,Y);
-
- int state = _view->getState();
-
- //Evaluate new state
- if(!_model->hasChanged() && state==HIGHLIGHTED)
- {
- _view->isStartDragging(true);
- _view->setState(DRAG);
- _model->setChanged();
- }
-
- if( !_model->hasChanged() && state == SELECTED)
- {
- if(_view->isPointInside(X,Y))
- {
- _view->isStartDragging(true);
- _view->setState(DRAG);
- _model->setChanged();
- }
- }
+ int state = _view->getState();
- _model->notifyObservers(_id);
+ //Evaluate new state
+ if(state == HIGHLIGHTED)
+ {
+ _isLeftClickDown=true;
+ _view->setState(SELECTED);
+ _model->notifyObservers(_id,ADD_TO_SELECTED);
}
return true;
+
}
//=========================================================================
bool GBlackBoxController::OnLeftButtonUp()
{
- if ( _vtkInteractorStyleBaseView!=NULL )
- {
- int X,Y;
- wxVTKRenderWindowInteractor *wxVTKiren;
- wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
- wxVTKiren->GetEventPosition(X,Y);
+ int X,Y;
+ wxVTKRenderWindowInteractor *wxVTKiren;
+ wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
+ wxVTKiren->GetEventPosition(X,Y);
- int state = _view->getState();
+ int state = _view->getState();
- //Evaluate new state
- if(!_model->hasChanged() && state==CLICKED)
- {
- _view->setState(SELECTED);
- _model->setChanged();
- }
-
- if( !_model->hasChanged() && state == DRAG)
+ //Evaluate new state
+ if(_isLeftClickDown)
+ {
+ _isLeftClickDown=false;
+ if(_view->isPointInside(X,Y))
{
+ // It is supposed that I'm always inside even if the box is in drag
_view->setState(SELECTED);
- _model->setChanged();
+ _model->notifyObservers(_id);
}
-
- _model->notifyObservers(_id);
-
}
return true;
+
}
//=========================================================================
bool GBlackBoxController::OnLeftDClick()
{
- if ( _vtkInteractorStyleBaseView!=NULL )
- {
- int X,Y;
- wxVTKRenderWindowInteractor *wxVTKiren;
- wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
- wxVTKiren->GetEventPosition(X,Y);
-
- _model->notifyObservers(_id);
- }
+
return true;
}
bool GBlackBoxController::OnRightButtonDown()
{
- if( _vtkInteractorStyleBaseView!= NULL )
- {
- 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);
- }
return true;
}