From 547ca8b4d40e607106fe9baae8a6679925d7dd42 Mon Sep 17 00:00:00 2001 From: davila <> Date: Mon, 4 Oct 2010 05:14:24 +0000 Subject: [PATCH] no message --- .../GConnectorModel.cxx | 15 ++ .../bbsKernelEditorGraphic/GlobalConstants.h | 6 +- .../GBlackBoxController.cxx | 46 +++--- .../GConnectorController.cxx | 2 - .../vtkGConnectorView.cxx | 3 +- .../bbtkwxGUIEditorGraphicBBS.cxx | 4 +- .../wxVtkSceneManager.cxx | 142 +++++++++++------- .../bbsWxGUIEditorGraphic/wxVtkSceneManager.h | 4 +- 8 files changed, 140 insertions(+), 82 deletions(-) diff --git a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GConnectorModel.cxx b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GConnectorModel.cxx index ebdf371..2956f0d 100644 --- a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GConnectorModel.cxx +++ b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GConnectorModel.cxx @@ -157,6 +157,8 @@ namespace bbtk void GConnectorModel::save(std::string &content) { + char buffer[50]; + content+="CONNECTION\n"; // Connection info @@ -168,6 +170,19 @@ namespace bbtk content+=":"; content+=_endPort->getBBTKName(); content+="\n"; + + int i,sizeLstPoints = _model->GetSizeLstPoints()-2; + content+="NumberOfControlPoints:"; + sprintf (buffer, "%d", sizeLstPoints ); + content+=buffer; + content+="\n"; + + for (i=0;iGetManualPoint(i+1); + sprintf (buffer, "%f:%f:%f\n", (float)mp->GetX(),(float)mp->GetY(),(float)mp->GetZ() ); + content+=buffer; + } } //========================================================================= diff --git a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GlobalConstants.h b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GlobalConstants.h index 639485d..54244a1 100644 --- a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GlobalConstants.h +++ b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GlobalConstants.h @@ -71,9 +71,9 @@ namespace bbtk const int INIT_CREATION_CONTOUR = 202; const int FIN_CREATION_CONTOUR = 203; const int ADD_TO_SELECTED = 204; - const int REMOVE_FROM_SELECTED = 205; - const int DRAG_OBJECTS = 206; - const int EDIT_BLACKBOX = 207; + const int DRAG_OBJECTS = 205; + const int EDIT_BLACKBOX = 206; + const int REMOVE_FROM_SELECTED = 207; //// COLORS (object_state_(R|G|B)) diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBlackBoxController.cxx b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBlackBoxController.cxx index 6cf2b9c..0480ece 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBlackBoxController.cxx +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBlackBoxController.cxx @@ -55,8 +55,6 @@ namespace bbtk bool GBlackBoxController::OnMouseMove() { -printf("EED GBlackBoxController::OnMouseMove START \n"); - if ( _vtkInteractorStyleBaseView!=NULL) { int X,Y; @@ -90,7 +88,6 @@ printf("EED GBlackBoxController::OnMouseMove START \n"); _objHasBeenMoved=true; } // state -printf("EED GBlackBoxController::OnMouseMove state=%d\n", state); _model->notifyObservers(getId()); } @@ -104,34 +101,40 @@ printf("EED GBlackBoxController::OnMouseMove state=%d\n", state); _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; - } //========================================================================= @@ -140,7 +143,6 @@ printf("EED GBlackBoxController::OnLeftButtonDown END\n" ); { _isLeftClickDown = false; int state = _view->getState(); -printf("EED GBlackBoxController::OnLeftButtonUp START state=%d \n", state); //Evaluate new state @@ -162,8 +164,11 @@ printf("EED GBlackBoxController::OnLeftButtonUp START state=%d \n", 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); @@ -171,7 +176,6 @@ printf("EED GBlackBoxController::OnLeftButtonUp START state=%d \n", state); } -printf("EED GBlackBoxController::OnLeftButtonUp END state=%d \n", state); return true; @@ -193,7 +197,7 @@ printf("EED GBlackBoxController::OnLeftButtonUp END state=%d \n", state); wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor(); wxVTKiren->GetEventPosition(X,Y); - int state = _view->getState(); +// int state = _view->getState(); //Evaluate new state if(_view->isPointInside(X,Y)) diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GConnectorController.cxx b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GConnectorController.cxx index c97055f..ce8717a 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GConnectorController.cxx +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GConnectorController.cxx @@ -137,7 +137,6 @@ namespace bbtk bool GConnectorController::OnRightButtonDown() { -printf ("GConnectorController::OnRightButtonDown 1 \n" ); if( _vtkInteractorStyleBaseView!= NULL ) { int X,Y; @@ -148,7 +147,6 @@ printf ("GConnectorController::OnRightButtonDown 1 \n" ); _controller->MouseClickRight(X,Y); } -printf ("GConnectorController::OnRightButtonDown 2 \n" ); return true; } diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGConnectorView.cxx b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGConnectorView.cxx index f9b17a0..c3f207a 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGConnectorView.cxx +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGConnectorView.cxx @@ -69,11 +69,12 @@ namespace bbtk //========================================================================= void vtkGConnectorView::updateStartEndPoints() - { + { GConnectorModel* mod=(GConnectorModel*)_model; mod->updateStartEndPoints(); manViewContour->RefreshContour(); } + } // EO namespace bbtk diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx index 848ca2e..c0892ab 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx @@ -454,7 +454,7 @@ namespace bbtk // writing file header content += "# ----------------------------------\n"; - content += "# - BBTKGEditor v 1.0 BBS BlackBox Script\n"; + content += "# - BBTKGEditor v 1.1 BBS BlackBox Script\n"; content += "# ----------------------------------\n"; content += "\n"; content += _tabsMgr->getActualDiagramBBS(); @@ -517,7 +517,7 @@ namespace bbtk // writing file header content += "# ----------------------------------\n"; - content += "# - BBTKGEditor v 1.0 BBG BlackBox Diagram file\n"; + content += "# - BBTKGEditor v 1.1 BBG BlackBox Diagram file\n"; content += "# - "; content += (const char*) (fileName.mb_str()); diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx index de07bcb..3d551fe 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx @@ -58,7 +58,7 @@ namespace bbtk { //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 @@ -132,7 +132,6 @@ namespace bbtk _fillObjectActor = vtkActor::New(); _pts = vtkPoints::New(); -//ups4 EED Borrame double w=100,h=10,b=h/15,t=3; _pts->SetNumberOfPoints(21); @@ -598,7 +597,6 @@ printf("EED wxVtkSceneManager::createGComplexBoxOutputPort 900-450\n"); void wxVtkSceneManager::update(int idController,int command) { -printf("EED wxVtkSceneManager::update 1 \n" ); if(command != NO_COMMAND) { @@ -667,20 +665,17 @@ printf("EED wxVtkSceneManager::update 1 \n" ); 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(); @@ -707,8 +702,6 @@ printf("EED wxVtkSceneManager::update 1 \n" ); } -printf("EED wxVtkSceneManager::update 2 \n" ); - } //========================================================================= @@ -740,6 +733,7 @@ printf("EED wxVtkSceneManager::update 2 \n" ); std::map::iterator it; + for(it = _controllers.begin(); it != _controllers.end(); ++it) { GObjectController *desc = it->second; @@ -781,7 +775,6 @@ printf("EED wxVtkSceneManager::update 2 \n" ); _textActor->SetScale(0.1); _textActor->SetPosition( px-25 ,py+1 , pz+2 ); -//ups4 EED Borrame // FillPortText px=px-33; py=py; @@ -804,8 +797,6 @@ printf("EED wxVtkSceneManager::update 2 \n" ); _textActor->SetScale(0.0001); _fillObjectActor->SetScale(0.0001); } - - return true; } @@ -813,6 +804,7 @@ printf("EED wxVtkSceneManager::update 2 \n" ); bool wxVtkSceneManager::OnLeftButtonDown() { + if(_worldState==INIT_CREATION_CONTOUR) { bool isOverPort=false; @@ -822,8 +814,8 @@ printf("EED wxVtkSceneManager::update 2 \n" ); 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; @@ -850,38 +842,38 @@ printf("EED wxVtkSceneManager::update 2 \n" ); 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; } @@ -972,7 +964,7 @@ printf("EED wxVtkSceneManager::OnLeftButtonDown 2 \n" ); } //========================================================================= - bool wxVtkSceneManager::UnSelectBlackBoxes() + void wxVtkSceneManager::UnSelectBlackBoxes() { for (int i=0; i< (int)_selectedObjects.size(); i++) { @@ -1691,6 +1683,7 @@ printf("EED wxVtkSceneManager::OnLeftButtonDown 2 \n" ); void wxVtkSceneManager::loadDiagram(ifstream &inputStream) { + std::string version; std::string line=""; char delims[] = ":"; char *result = NULL; @@ -1702,6 +1695,12 @@ printf("EED wxVtkSceneManager::OnLeftButtonDown 2 \n" ); 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") { @@ -1953,11 +1952,51 @@ printf("EED wxVtkSceneManager::OnLeftButtonDown 2 \n" ); 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> 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(); } //========================================================================= @@ -2031,7 +2070,7 @@ printf("EED wxVtkSceneManager::OnLeftButtonDown 2 \n" ); //========================================================================= - 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) { @@ -2051,7 +2090,7 @@ printf("EED wxVtkSceneManager::OnLeftButtonDown 2 \n" ); endP = boxModel->getInputPort(nameEndPort); } - +//ups2 int idCon = createGConnector(startP); _worldState = NOTHING_HAPPENS; GConnectorController *tempp = (GConnectorController*)_controllers[idCon]; @@ -2061,6 +2100,7 @@ printf("EED wxVtkSceneManager::OnLeftButtonDown 2 \n" ); tempp->endContourCreation(); conMod->setEndPort(endP); conView->updateStartEndPoints(); + return idCon; } //========================================================================= diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.h b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.h index d7a4011..82c2052 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.h +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.h @@ -119,7 +119,7 @@ namespace bbtk int createGConnector(GPortModel* startPort); void configGBlackBox(int idBox, double xIn, double yIn, double zIn, std::string name, bool boxExecutable,double xEn,double yEn,double zEn); - void configGConnetion( std::string nameStartBox, std::string nameStartPort, std::string + int configGConnetion( std::string nameStartBox, std::string nameStartPort, std::string nameEndBox, std::string nameEndPort); void configGComBoxInputOutputPort(bool inputoutput, std::string inputPortName, double xIn, double yIn,double zIn); GBoxModel* findGBox(std::string boxname); @@ -231,7 +231,7 @@ namespace bbtk std::string LineNumber(bool withLineNumber, int &value); int GetIndexInSelected(int idControler); - bool UnSelectBlackBoxes(); + void UnSelectBlackBoxes(); GObjectController *GetGBlackBoxControlerPointedByMouse(); -- 2.47.1