return temp;
}
+ //=========================================================================
+
+
} // EO namespace bbtk
// EOF
}
//=========================================================================
+ void GObjectModel::getCenter(double& x, double& y, double& z)
+ {
+ x = (_xInic+_xFin)/2;
+ y = (_yInic+_yFin)/2;
+ z = (_zInic+_zFin)/2;
+ }
+ //=========================================================================
+
void GObjectModel::setInicPoint(double& x, double& y, double& z)
{
_xInic = x;
void getInicPoint(double& x, double& y, double& z);
void getFinalPoint(double& x, double& y, double& z);
+ 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);
posY = yFin;
}
- //Usually pos begins in 0
+ //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;
setInicPoint(posX,posY,posZ);
const int CREATING_CONTOUR=106;
// Object dimensions
- const double BOX_HEIGHT=15;
- const double BOX_WIDTH=100;
- const double PORT_HEIGHT=3;
- const double PORT_WIDTH=3;
+ const double BOX_HEIGHT = 15;
+ const double BOX_WIDTH = 100;
+ const double PORT_HEIGHT = 2;
+ const double PORT_WIDTH = 2;
// Commands
const int REPAINT = 201;
void Observable::addObserver(Observer *observer)
{
- std::cout<<"RaC Observable::addObserver "<<observer<<std::endl;
_observers.push_back(observer);
}
iren->SetInteractorStyle(interactorstylebaseview);
interactorstylebaseview->SetwxVtkBaseView(_baseView);
- double posCamera[3];
_baseView->GetRenderer()->GetActiveCamera()->ParallelProjectionOn();
- _baseView->GetRenderer()->GetActiveCamera()->SetPosition(0,0,1000);
- _baseView->GetRenderer()->GetActiveCamera()->GetPosition(posCamera);
- _baseView->GetRenderer()->ResetCamera();
- _baseView->GetRenderer()->ResetCameraClippingRange();
+ _baseView->GetRenderer()->ResetCamera(-100,100,-100,100,900,900);
_baseView->GetRenderer()->SetBackground(0.9,0.9,0.9);
int cantObjects = _objects.size();
cantObjects++;
std::stringstream stream;
- stream << "Box " << cantObjects;
+ stream << "Box:Algo " << cantObjects;
std::string arraystring = stream.str();
model->setBBTKName(arraystring);
manualContourControler* manContourControl = new manualContourControler();
GConnectorView* manViewerContour = new GConnectorView();
manualContourModel* manContourModel = new manualContourModel();
+ manContourModel->SetCloseContour(false);
-
manViewerContour->SetModel( manContourModel );
manViewerContour->SetWxVtkBaseView( _baseView );
manViewerContour->SetRange( 0.5 );
manContourControl->SetModelView( manContourModel , manViewerContour );
manContourControl->Configure();
int i,sizeLstPoints = manContourModel->GetSizeLstPoints();
- //std::cout<<"RaC wxVtkSceneManager::createGConnector "<<this<<" size:"<<sizeLstPoints<<std::endl;
+
for ( i=0; i<sizeLstPoints; i++ )
{
manViewerContour->AddPoint();
}
manContourControl->CreateNewManualContour();
- manViewerContour->RefreshContour();
+
+ manViewerContour->RefreshContour();
+
registerController((InteractorStyleMaracas*) manContourControl);
}
}
//=========================================================================
+ bool GBlackBoxController::OnMouseMove()
+ {
+
+ 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 == DRAG)
+ {
+ moveObject(X,Y);
+ _model->setChanged();
+ }
+
+ if(!_model->hasChanged() && state == NOTHING_HAPPENS)
+ {
+ if(_view->isPointInside(X,Y))
+ {
+ _model->setState(HIGHLIGHTED);
+ _model->setChanged();
+ }
+ }
+ if(!_model->hasChanged() && state==HIGHLIGHTED)
+ {
+ if(!_view->isPointInside(X,Y))
+ {
+ _model->setState(NOTHING_HAPPENS);
+ _model->setChanged();
+ }
+ }
+
+ _model->notifyObservers();
+ }
+ return true;
+ }
+
+ //=========================================================================
+
+ bool GBlackBoxController::OnLeftButtonDown()
+ {
+
+ 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==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();
+ }
+ return true;
+ }
+
+ //=========================================================================
+
+ bool GBlackBoxController::OnLeftButtonUp()
+ {
+ 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();
+
+ }
+ return true;
+ }
+
+ //=========================================================================
+
+ bool GBlackBoxController::OnLeftDClick()
+ {
+ if ( _vtkInteractorStyleBaseView!=NULL )
+ {
+ int X,Y;
+ wxVTKRenderWindowInteractor *wxVTKiren;
+ wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
+ wxVTKiren->GetEventPosition(X,Y);
+
+ _model->notifyObservers();
+ }
+ return true;
+ }
+
+ //=========================================================================
+
+ bool GBlackBoxController::OnRightButtonDown()
+ {
+ 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 == SELECTED)
+ {
+ _model->setState(NOTHING_HAPPENS);
+ _model->setChanged();
+ }
+
+ _model->notifyObservers();
+ }
+ return true;
+}
//=========================================================================
~GBlackBoxController();
//Public methods
-
+ virtual bool OnMouseMove();
+ virtual bool OnLeftButtonDown();
+ virtual bool OnLeftButtonUp();
+ virtual bool OnLeftDClick();
+ virtual bool OnRightButtonDown();
private:
bool GObjectController::OnMouseMove()
{
+ /********************** VIRTUAL *************************/
+
if ( _vtkInteractorStyleBaseView!=NULL)
{
int X,Y;
_model->notifyObservers();
}
+
+ /**/
+
return true;
}
//=========================================================================
bool GObjectController::OnLeftButtonDown()
{
+ /********************** VIRTUAL *************************
if ( _vtkInteractorStyleBaseView!=NULL )
{
//Evaluate new state
if(!_model->hasChanged() && state==HIGHLIGHTED)
{
- _view->isFirstDragging(true);
+ _view->isStartDragging(true);
_model->setState(DRAG);
_model->setChanged();
}
{
if(_view->isPointInside(X,Y))
{
- _view->isFirstDragging(true);
+ _view->isStartDragging(true);
_model->setState(DRAG);
_model->setChanged();
}
_model->notifyObservers();
}
+
+ */
+
return true;
}
//=========================================================================
bool GObjectController::OnLeftButtonUp()
{
+
+ /********************** VIRTUAL *************************
+
if ( _vtkInteractorStyleBaseView!=NULL )
{
int X,Y;
_model->notifyObservers();
}
+
+ */
return true;
}
//=========================================================================
bool GObjectController::OnLeftDClick()
{
+ /********************** VIRTUAL *************************
+
if ( _vtkInteractorStyleBaseView!=NULL )
{
int X,Y;
_model->notifyObservers();
}
+
+ */
return true;
}
//=========================================================================
bool GObjectController::OnRightButtonDown()
{
+ /********************** VIRTUAL *************************/
+
if( _vtkInteractorStyleBaseView!= NULL )
{
int X,Y;
_model->notifyObservers();
}
+
+ /**/
+
return true;
+
}
//=========================================================================
//=========================================================================
void vtkGBlackBoxView::update(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);
+ //_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);
+ //_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);
+ //_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);
+ //_nameActor->GetProperty()->SetColor(BOXCONTOUR_SELECTED_R,BOXCONTOUR_SELECTED_G,BOXCONTOUR_SELECTED_B);
_typeActor->GetProperty()->SetColor(BOXCONTOUR_SELECTED_R,BOXCONTOUR_SELECTED_G,BOXCONTOUR_SELECTED_B);
}
//-----------
- _baseView->GetRenWin()->Render();
+ _baseView->RefreshView();
+ _baseView->Refresh();
}
//=========================================================================
//------------
+ /*
_vectorNameText = vtkVectorText::New();
std::string temp = _model->getBBTKName();
_vectorNameText->SetText(temp.c_str());
txtMapper->SetInputConnection( _vectorNameText->GetOutputPort());
_nameActor = vtkActor::New();
_nameActor->SetMapper(txtMapper);
+ */
+
+ _vectorNameText = vtkTextActor3D::New();
+ std::string temp = _model->getBBTKName();
+ _vectorNameText->SetInput( temp.c_str() );
+
//------------
temp = _model->getBBTKType();
_vectorTypeText->SetText(temp.c_str());
- txtMapper = vtkPolyDataMapper::New();
+ vtkPolyDataMapper* txtMapper = vtkPolyDataMapper::New();
txtMapper->SetInputConnection( _vectorTypeText->GetOutputPort());
_typeActor = vtkActor::New();
_typeActor->SetMapper(txtMapper);
updatePositionTextActors( xInic, yInic, zInic);
- _nameActor->GetProperty()->SetColor(BOXCONTOUR_NH_R,BOXCONTOUR_NH_G,BOXCONTOUR_NH_B);
+ //_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(_nameActor);
+
+ _baseView->GetRenderer()->AddActor(_vectorNameText);
+
_baseView->GetRenderer()->AddActor(_typeActor);
vtkGObjectView::addVtkActors();
void vtkGBlackBoxView::updatePositionTextActors(double xInic, double yInic, double zInic)
{
- _nameActor->SetPosition(xInic+4,yInic-5,zInic);
- _nameActor->SetScale(3,2,1);
+ //_nameActor->SetPosition(xInic+4,yInic-5,zInic);
+ //_nameActor->SetScale(2,2,1);
+ _vectorNameText->SetPosition(xInic+4,yInic-5,zInic);
_typeActor->SetPosition(xInic+4,yInic-10,zInic);
- _typeActor->SetScale(3,2,1);
+ _typeActor->SetScale(2,2,1);
}
+ //=========================================================================
} // EO namespace bbtk
#include "vtkRenderer.h"
#include "vtkCellArray.h"
+#include "vtkTextActor3D.h"
+#include "vtkTextProperty.h"
+
//Includes std
#include <iostream>
vtkPoints *_pts;
vtkActor* _nameActor;
vtkActor* _typeActor;
- vtkVectorText* _vectorNameText;
+
+ //vtkVectorText* _vectorNameText;
+ vtkTextActor3D* _vectorNameText;
+
vtkVectorText* _vectorTypeText;
//Private Methods
{
_baseView=NULL;
_objectActor=NULL;
- _isFirstDragging=false;
+ _isStartDragging=false;
}
//=========================================================================
- if(_isFirstDragging)
+ if(_isStartDragging)
{
- _isFirstDragging=false;
+ _isStartDragging=false;
double xInic,yInic,zInic;
_model->getInicPoint(xInic,yInic,zInic);
//=========================================================================
- void vtkGObjectView::isFirstDragging(bool param)
+ void vtkGObjectView::isStartDragging(bool param)
{
- _isFirstDragging=param;
+ _isStartDragging=param;
dragDifX=0;
dragDifX=0;
}
virtual void moveObject(int X, int Y);
virtual void update(int command);
- void isFirstDragging(bool param);
+ void isStartDragging(bool param);
private:
//Private Attributes
- bool _isFirstDragging;
+ bool _isStartDragging;
double dragDifX;
double dragDifY;
//=========================================================================
void vtkGPortView::update(int command)
{
+ _objectActor->GetProperty()->SetColor(0.8,0.2,0.5);
if(_model->getState()==HIGHLIGHTED)
{
_objectActor->GetProperty()->SetColor(0.8,0.2,0.5);
_pts->SetPoint(2, xFin, yFin, zFin );
_pts->SetPoint(3, xFin, yInic, zFin );
- _baseView->GetRenderer()->Render();
- _baseView->GetRenWin()->Render();
+ //_baseView->GetRenderer()->Render();
+ //_baseView->GetRenWin()->Render();
}
switch (event.GetId())
{
case wxID_NEW :
- std::cout<<"RaC New"<<std::endl;
_tabsMgr->addNewTab();
break;
}