bool GBlackBoxController::OnMouseMove()
{
-printf("EED GBlackBoxController::OnMouseMove START \n");
-
if ( _vtkInteractorStyleBaseView!=NULL)
{
int X,Y;
_objHasBeenMoved=true;
} // state
-printf("EED GBlackBoxController::OnMouseMove state=%d\n", state);
_model->notifyObservers(getId());
}
_objHasBeenMoved = false;
_isLeftClickDown = true;
bool ok=true;
+
+ int X,Y;
+ wxVTKRenderWindowInteractor *_wxVTKiren;
+ _wxVTKiren= _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
+ _wxVTKiren->GetEventPosition( X , Y );
+
+
+
int state = _view->getState();
-printf("EED GBlackBoxController::OnLeftButtonDown state=%d \n", state);
//Evaluate new state
- if(state == HIGHLIGHTED)
+
+ if(_view->isPointInside(X,Y))
+
+// if(state == HIGHLIGHTED)
//EED3oct2010 if ( (state == HIGHLIGHTED) && (ctrlkey==1 ) )
{
ok=false;
_view->setState(SELECTED);
_model->notifyObservers(getId(),ADD_TO_SELECTED);
}
-
-
-
- int X,Y;
- wxVTKRenderWindowInteractor *wxVTKiren;
- wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
- wxVTKiren->GetEventPosition(X,Y);
- int ctrlkey=_vtkInteractorStyleBaseView->GetInteractor()->GetControlKey();
+
+
+ int shiftkey = _vtkInteractorStyleBaseView->GetInteractor()->GetShiftKey();
+ int ctrlkey = _vtkInteractorStyleBaseView->GetInteractor()->GetControlKey();
+ ctrlkey = ctrlkey + shiftkey;
+
+
if ( (state==DRAG) && (ctrlkey==1) && (_view->isPointInside(X,Y)==true) )
{
_view->setState(NOTHING_HAPPENS);
_model->notifyObservers(getId(),REMOVE_FROM_SELECTED);
}
-printf("EED GBlackBoxController::OnLeftButtonDown END\n" );
-
return ok;
-
}
//=========================================================================
{
_isLeftClickDown = false;
int state = _view->getState();
-printf("EED GBlackBoxController::OnLeftButtonUp START state=%d \n", state);
//Evaluate new state
- int ctrlkey=_vtkInteractorStyleBaseView->GetInteractor()->GetControlKey();
-
+ int shiftkey = _vtkInteractorStyleBaseView->GetInteractor()->GetShiftKey();
+ int ctrlkey = _vtkInteractorStyleBaseView->GetInteractor()->GetControlKey();
+ ctrlkey = ctrlkey + shiftkey;
+
+
if ( (state==SELECTED) && (ctrlkey==0) && (_objHasBeenMoved==false))
{
_view->setState(NOTHING_HAPPENS);
}
-printf("EED GBlackBoxController::OnLeftButtonUp END state=%d \n", state);
return true;
wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
wxVTKiren->GetEventPosition(X,Y);
- int state = _view->getState();
+// int state = _view->getState();
//Evaluate new state
if(_view->isPointInside(X,Y))
{
//EED02JUIN2010
printf ("RaC-EED 21-06-2010 %p wxVtkSceneManager::wxVtkSceneManager If you comment this line, the drag and drop functionnality is not initialized.\n" , this );
-#ifdef _APPLE_
+#ifdef __APPLE__
_baseView->GetWxVTKRenderWindowInteractor()->SetDropTarget((wxDropTarget*)parent);
#endif
_fillObjectActor = vtkActor::New();
_pts = vtkPoints::New();
-//ups4 EED Borrame
double w=100,h=10,b=h/15,t=3;
_pts->SetNumberOfPoints(21);
void wxVtkSceneManager::update(int idController,int command)
{
-printf("EED wxVtkSceneManager::update 1 \n" );
if(command != NO_COMMAND)
{
cont->SetActive(false);
}
}
-
_selectedObjects.clear();
-
_idConnectionInCreation=createGConnector(startOutputPort);
-
}
else if(command == FIN_CREATION_CONTOUR && _worldState == INIT_CREATION_CONTOUR)
{
- _worldState = NOTHING_HAPPENS;
+ _worldState = NOTHING_HAPPENS;
//int id = _controllers.size()-1;
- GObjectController* cont = _controllers[_idConnectionInCreation];
- GConnectorModel* modelContour = (GConnectorModel*)cont->getModel();
+ GObjectController *cont = _controllers[_idConnectionInCreation];
+ GConnectorModel *modelContour = (GConnectorModel*)cont->getModel();
+ GObjectController *finPort = _controllers[idController];
- GObjectController* finPort = _controllers[idController];
if(finPort->getGObjectType() == GPORT)
{
GPortModel* modelPort = (GPortModel*)finPort->getModel();
}
-printf("EED wxVtkSceneManager::update 2 \n" );
-
}
//=========================================================================
std::map<int, GObjectController*>::iterator it;
+
for(it = _controllers.begin(); it != _controllers.end(); ++it)
{
GObjectController *desc = it->second;
_textActor->SetScale(0.1);
_textActor->SetPosition( px-25 ,py+1 , pz+2 );
-//ups4 EED Borrame
// FillPortText
px=px-33;
py=py;
_textActor->SetScale(0.0001);
_fillObjectActor->SetScale(0.0001);
}
-
-
return true;
}
bool wxVtkSceneManager::OnLeftButtonDown()
{
+
if(_worldState==INIT_CREATION_CONTOUR)
{
bool isOverPort=false;
GObjectController *desc = it->second;
if(desc->getGObjectType()==GPORT)
{
- GPortModel* portmod=(GPortModel*)desc->getModel();
- vtkGObjectView* portView=desc->getView();
+ GPortModel *portmod = (GPortModel*)desc->getModel();
+ vtkGObjectView *portView = desc->getView();
if(portmod->getPortType()==GINPUTPORT && portView->getState()==HIGHLIGHTED)
{
isOverPort=true;
desc->getModel()->notifyObservers(_idManager);
} // for
} // isOverPort
- } // _worldState
-
- _worldState = DRAG_OBJECTS;
- _startDragging = true;
-
-printf("EED wxVtkSceneManager::OnLeftButtonDown 1 \n" );
-
-
- int ctrlkey = _vtkInteractorStyleBaseView->GetInteractor()->GetControlKey();
- GObjectController *cont = GetGBlackBoxControlerPointedByMouse();
-
- if (GetGBlackBoxControlerPointedByMouse()!=NULL)
- {
- int state=cont->getView()->getState() ;
- if( (ctrlkey==0) && (state==HIGHLIGHTED) )
- {
- UnSelectBlackBoxes();
- }
- }
-
-
- for (int i = 0; i < (int)_selectedObjects.size(); i++)
- {
- int id = _selectedObjects[i];
- GObjectController* cont = _controllers[id];
- cont->getView()->setState(DRAG);
- cont->getModel()->notifyObservers(_idManager);
- } // for
+ } else { //_worldState
+
+ _worldState = DRAG_OBJECTS;
+ _startDragging = true;
+
+ int shiftkey = _vtkInteractorStyleBaseView->GetInteractor()->GetShiftKey();
+ int ctrlkey = _vtkInteractorStyleBaseView->GetInteractor()->GetControlKey();
+ ctrlkey = ctrlkey + shiftkey;
+
+ GObjectController *cont = GetGBlackBoxControlerPointedByMouse();
+
+
+ if (GetGBlackBoxControlerPointedByMouse()!=NULL)
+ {
+ int state=cont->getView()->getState() ;
+ if( (ctrlkey==0) && (state==HIGHLIGHTED) )
+ {
+ UnSelectBlackBoxes();
+ }
+ }
+ for (int i = 0; i < (int)_selectedObjects.size(); i++)
+ {
+ int id = _selectedObjects[i];
+ GObjectController* cont = _controllers[id];
+ cont->getView()->setState(DRAG);
+ cont->getModel()->notifyObservers(_idManager);
+ } // for
-printf("EED wxVtkSceneManager::OnLeftButtonDown 2 \n" );
+ } // if _selectedObjects.size
+
return true;
}
}
//=========================================================================
- bool wxVtkSceneManager::UnSelectBlackBoxes()
+ void wxVtkSceneManager::UnSelectBlackBoxes()
{
for (int i=0; i< (int)_selectedObjects.size(); i++)
{
void wxVtkSceneManager::loadDiagram(ifstream &inputStream)
{
+ std::string version;
std::string line="";
char delims[] = ":";
char *result = NULL;
if(line=="" || line[0]=='#')
{
getline(inputStream,line);
+ if (line=="# - BBTKGEditor v 1.0 BBG BlackBox Diagram file")
+ {
+ version=line.substr(18,3);
+ printf("EED wxVtkSceneManager::loadDiagram version=%s\n",version.c_str());
+ }
+
}
else if(line=="APP_START")
{
result = strtok( NULL, delims );
std::string nameEndPort(result);
- configGConnetion(nameStartBox, nameStartPort, nameEndBox, nameEndPort);
+ int idCon = configGConnetion(nameStartBox, nameStartPort, nameEndBox, nameEndPort);
+
+ if (version!="1.0")
+ {
+ //Readding control points of the manualContour
+ //ups1
+ GConnectorController *tempp = (GConnectorController*)_controllers[idCon];
+ GConnectorModel *conMod = (GConnectorModel*)tempp->getModel();
+ vtkGConnectorView *conView= (vtkGConnectorView*)tempp->getView();
+ getline(inputStream,line); //NumberOfControlPoints:##
+ strcpy( conns, line.c_str() );
+ result = strtok( conns, delims );
+ result = strtok( NULL, delims );
+
+ int numberOfControlPoints;
+ std::istringstream isCons(result);
+ isCons >> numberOfControlPoints;
+
+ for (int ii=0;ii<numberOfControlPoints;ii++)
+ {
+ getline(inputStream,line); //XX:YY:ZZ
+ char connec[200];
+ strcpy( connec, line.c_str() );
+
+ double px,py,pz;
+ result = strtok( connec, delims );
+ std::istringstream isPointX(result);
+ isPointX >> px;
+ result = strtok( NULL, delims );
+ std::istringstream isPointY(result);
+ isPointY >> py;
+ result = strtok( NULL, delims );
+ std::istringstream isPointZ(result);
+ isPointZ >> pz;
+
+ conMod->getManualContourModel()->InsertPoint_id(ii+1,px,py,pz);
+ conView->getManualContourView()->AddPoint();
+ }
+ }// version !=1.0
+
} // for numConns
} // start
-
+
+ refresh();
}
//=========================================================================
//=========================================================================
- void wxVtkSceneManager::configGConnetion(std::string nameStartBox, std::string nameStartPort, std::string
+ int wxVtkSceneManager::configGConnetion(std::string nameStartBox, std::string nameStartPort, std::string
nameEndBox, std::string nameEndPort)
{
endP = boxModel->getInputPort(nameEndPort);
}
-
+//ups2
int idCon = createGConnector(startP);
_worldState = NOTHING_HAPPENS;
GConnectorController *tempp = (GConnectorController*)_controllers[idCon];
tempp->endContourCreation();
conMod->setEndPort(endP);
conView->updateStartEndPoints();
+ return idCon;
}
//=========================================================================