_xFin = 0;
_yFin = 0;
_zFin = 900;
+ _state = NOTHING_HAPPENS;
}
//=========================================================================
void GObjectModel::getFinalPoint(double& x, double& y, double& z)
{
x = _xInic+BOX_SIDE;
- y = _yInic+BOX_SIDE;
+ y = _yInic-BOX_SIDE;
z = _zFin;
}
//=========================================================================
}
//=========================================================================
+ void GObjectModel::setState(int state)
+ {
+ _state = state;
+ }
+
+ //=========================================================================
+
+ int GObjectModel::getState()
+ {
+ return _state;
+ }
+ //=========================================================================
+
+ bool GObjectModel::isPointInside(double x,double y, double z)//virtual
+ {
+ if(x>=_xInic && x<=_xFin && y<=_yInic && y>=_yFin)
+ return true;
+ else
+ return false;
+ }
+
+ //=========================================================================
} // EO namespace bbtk
void getFinalPoint(double& x, double& y, double& z);
void setInicPoint(double& x, double& y, double& z);
void setFinalPoint(double& x, double& y, double& z);
+ void setState(int state);
+ int getState();
+ virtual bool isPointInside(double x,double y, double z);
private:
double _yFin;
double _zFin;
- //Protected methods
+ int _state;
+ //Protected methods
+
};
{
vtkInteractorStyleImage *temp = vtkInteractorStyleImage::New();
_baseView->GetWxVTKRenderWindowInteractor()->SetInteractorStyle(temp);
- _baseView->GetRenderer()->SetActiveCamera(_baseView->GetCamera());
- _baseView->GetRenderer()->ResetCamera ();
- _baseView->GetCamera()->SetParallelProjection(true);
+ //_baseView->GetRenderer()->SetActiveCamera(_baseView->GetCamera());
+ //_baseView->GetRenderer()->ResetCamera ();
+ //_baseView->GetCamera()->SetParallelProjection(true);
+
+ _baseView->GetRenderer()->SetBackground(1,1,1);
_baseView->Refresh();
-
}
//=========================================================================
GObjectController* controller = GObjectsMVCFactory::getInstance()->createGObjectController(type);
//Prepares the initial model
+ cout<<"RaC Size:"<<_baseView->GetRenWin()->GetSize()[1]<<endl;
double xx = x;
- double yy = y;
- double zz = 900;
+ double yy = _baseView->GetRenWin()->GetSize()[1]-y;
+ double zz = 0;
_baseView->TransCoordScreenToWorld(xx,yy,zz);
//(NOTE: Refresh is only made by the view)
model->setInicPoint(xx,yy,zz);
view->setModel(model);
- view->setRenderer(_baseView->GetRenderer());
+ view->setBaseView(_baseView);
view->initVtkObjects();
//Refresh renderwindow with new objects
void wxVtkSceneManager::registerController(InteractorStyleMaracas *param)
{
+ cout<<"RaC wxVtkSceneManager::registerController param:"<<param<<endl;
vtkInteractorStyleBaseView* baseViewControlManager = (vtkInteractorStyleBaseView*)_baseView->GetInteractorStyleBaseView();
baseViewControlManager->AddInteractorStyleMaracas( param );
}
}
//=========================================================================
+ bool wxVtkSceneManager::OnMouseMove()
+ {
+ cout<<"RaC wxVtkSceneManager::OnMouseMove "<<endl;
+ return true;
+ }
//=========================================================================
} // EO namespace bbtk
vtkRenderWindow* getRenderWindow();
vtkRenderer* getRenderer();
void disconnectDrop();
+ virtual bool OnMouseMove();
private:
}
//=========================================================================
+bool GObjectController::OnMouseMove()
+{
+ cout<<"RaC GObjectController::OnMouseMove "<<endl;
+ if ( _vtkInteractorStyleBaseView!=NULL)
+ {
+ int X,Y;
+ wxVTKRenderWindowInteractor *_wxVTKiren;
+ _wxVTKiren= _vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->GetWxVTKRenderWindowInteractor();
+ _wxVTKiren->GetEventPosition( X , Y );
+
+ int state = _model->getState();
+
+ //Evaluate new state
+ if(state == CLICKED)
+ {
+ _model->setState(DRAG);
+ //MoveObject(X,Y);
+
+ }
+ if(state == DRAG)
+ {
+ //MoveObject(X,Y);
+
+ }
+ if(state == NOTHING_HAPPENS)
+ {
+ if(_view->isPointInside(X,Y))
+ {
+ _model->setState(HIGHLIGHTED);
+ }
+ }
+
+ _view->refresh();
+ }
+ return true;
+}
+//=========================================================================
+bool GObjectController::OnLeftButtonDown()
+{
+
+ if ( _vtkInteractorStyleBaseView!=NULL )
+ {
+ int X,Y;
+ wxVTKRenderWindowInteractor *wxVTKiren;
+ wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->GetWxVTKRenderWindowInteractor();
+ wxVTKiren->GetEventPosition(X,Y);
+
+ //MouseClickLeft(X,Y);
+ }
+ return true;
+}
+//=========================================================================
+bool GObjectController::OnLeftButtonUp()
+{
+ if ( _vtkInteractorStyleBaseView!=NULL )
+ {
+ int X,Y;
+ wxVTKRenderWindowInteractor *wxVTKiren;
+ wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->GetWxVTKRenderWindowInteractor();
+ wxVTKiren->GetEventPosition(X,Y);
+ //MouseReleaseLeft(X,Y);
+ }
+ return true;
+}
+//=========================================================================
+bool GObjectController::OnLeftDClick()
+{
+ if ( _vtkInteractorStyleBaseView!=NULL )
+ {
+ int X,Y;
+ wxVTKRenderWindowInteractor *wxVTKiren;
+ wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->GetWxVTKRenderWindowInteractor();
+ wxVTKiren->GetEventPosition(X,Y);
+
+ //this->MouseDLeft(X,Y);
+ }
+ return true;
+}
+//=========================================================================
+bool GObjectController::OnMiddleButtonDown()
+{
+ if ( _vtkInteractorStyleBaseView!=NULL )
+ {
+ int X,Y;
+ wxVTKRenderWindowInteractor *wxVTKiren;
+ wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->GetWxVTKRenderWindowInteractor();
+ wxVTKiren->GetEventPosition(X,Y);
+ //GetManualViewBaseContour()->InitMove( X, Y,GetZ());
+ }
+ return true;
+}
+//=========================================================================
+bool GObjectController::OnMiddleButtonUp()
+{
+ return true;
+}
+//=========================================================================
+bool GObjectController::OnRightButtonDown()
+{
+ if( _vtkInteractorStyleBaseView!= NULL )
+ {
+ int X,Y;
+ wxVTKRenderWindowInteractor *wxVTKiren;
+ wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->GetWxVTKRenderWindowInteractor();
+ wxVTKiren->GetEventPosition(X, Y);
+
+ //SetCompleteCreation( true );
+ //SetKeyBoardMoving( false );
+ //this->GetManualContourModel()->SetCloseContour(true);
+ //MouseClickRight(X,Y);
+ }
+ return true;
+}
+//=========================================================================
+bool GObjectController::OnRightButtonUp()
+{
+ return true;
+}
+//=========================================================================
+
} // EO namespace bbtk
// EOF
protected:
+ //Protected Attributes
+
+
+ //Protected Methods
+ virtual bool OnMouseMove();
+ virtual bool OnLeftButtonDown();
+ virtual bool OnLeftButtonUp();
+ virtual bool OnLeftDClick();
+ virtual bool OnMiddleButtonDown();
+ virtual bool OnMiddleButtonUp();
+ virtual bool OnRightButtonDown();
+ virtual bool OnRightButtonUp();
+
};
#include "vtkGObjectView.h"
//Includes creaMaracasVisu
-#include <wxVtk3DBaseView.h>
//Includes vtk
-#include <vtkRenderer.h>
#include "vtkPolyDataMapper.h"
#include "vtkActor.h"
//=========================================================================
vtkGObjectView::vtkGObjectView()
{
- _renderer=NULL;
+ _baseView=NULL;
_objectActor=NULL;
}
void vtkGObjectView::refresh()
{
+ if(_model->getState()==NOTHING_HAPPENS)
+ {
+ _objectActor->GetProperty()->SetColor(0,0,0);
+ }
+
+ if(_model->getState()==HIGHLIGHTED)
+ {
+ _objectActor->GetProperty()->SetColor(1,0,0);
+ }
+
//paint();
}
//=========================================================================
- void vtkGObjectView::setRenderer(vtkRenderer* renderer)
+ void vtkGObjectView::setBaseView(wxVtkBaseView* baseView)
{
- _renderer=renderer;
+ _baseView=baseView;
}
//=========================================================================
void vtkGObjectView::addVtkActors()//virtual
{
- _renderer->AddActor(_objectActor);
- _renderer->Render();
+ _baseView->GetRenderer()->AddActor(_objectActor);
+ _baseView->GetRenderer()->Render();
+ }
+
+ //=========================================================================
+
+ bool vtkGObjectView::isPointInside(int X,int Y)
+ {
+ double xx=X,yy=Y,zz=0;
+ _baseView->TransCoordScreenToWorld(xx,yy,zz);
+ return _model->isPointInside(xx,yy,zz);
}
//=========================================================================
#include "GObjectModel.h"
//Includes creaMaracasVisu
-#include <wxVtk3DBaseView.h>
+#include <wxVtkBaseView.h>
//Includes vtk
#include <vtkRenderer.h>
//Public methods
void setModel(GObjectModel *model);
- void setRenderer(vtkRenderer* renderer);
+ void setBaseView(wxVtkBaseView* baseView);
void initVtkObjects();
+
+ bool isPointInside(int X,int Y);
virtual void refresh();
protected:
//Protected Attributes
- vtkRenderer *_renderer;
+ wxVtkBaseView *_baseView;
GObjectModel *_model;
vtkActor *_objectActor;