]> Creatis software - bbtkGEditor.git/commitdiff
no message
authordavila <>
Mon, 4 Oct 2010 05:14:24 +0000 (05:14 +0000)
committerdavila <>
Mon, 4 Oct 2010 05:14:24 +0000 (05:14 +0000)
lib/EditorGraphicBBS/bbsKernelEditorGraphic/GConnectorModel.cxx
lib/EditorGraphicBBS/bbsKernelEditorGraphic/GlobalConstants.h
lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBlackBoxController.cxx
lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GConnectorController.cxx
lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGConnectorView.cxx
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.h

index ebdf3715aeb5d46cc7854e77ed81c671fb2ded28..2956f0dc383fc7ea07a17502f2a1d53488e839be 100644 (file)
@@ -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;i<sizeLstPoints;i++)
+               {
+                       manualPoint *mp = _model->GetManualPoint(i+1);
+                       sprintf (buffer, "%f:%f:%f\n", (float)mp->GetX(),(float)mp->GetY(),(float)mp->GetZ() );
+                       content+=buffer;
+               }               
        }
 
        //=========================================================================
index 639485d42f2c0c42f13efae28928b0196945955b..54244a1cb464a7d36e52ba98806f6c94d381e914 100644 (file)
@@ -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))
index 6cf2b9c99f7ed935144241ca40375a52a39dba0d..0480ece566d47accda9b61f7b89d4adfdac314e5 100644 (file)
@@ -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))
index c97055f814ef5b80ae9563b953c152e233abe76d..ce8717aee8991eae3ede989e0d2cc12bb50d8d2d 100644 (file)
@@ -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;
        }
 
index f9b17a014d08a794bddccd52b366671e5e641a22..c3f207aa4d5fa2d7b7e6ddafb17d046caa854fe5 100644 (file)
@@ -69,11 +69,12 @@ namespace bbtk
        //=========================================================================
        
        void vtkGConnectorView::updateStartEndPoints()
-       {
+       {               
                GConnectorModel* mod=(GConnectorModel*)_model;
                mod->updateStartEndPoints();
                manViewContour->RefreshContour();
        }
+               
 
 }  // EO namespace bbtk
 
index 848ca2efe6a9909775bc6b60efddceaf07643ac4..c0892ab522855bebcf1a574512b952a8ee03b38a 100644 (file)
@@ -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());
index de07bcb8ee13796df554b65938d8522d2d52d6b6..3d551feec6900e36cdf8fc5cd8aee482b94fecc2 100644 (file)
@@ -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<int, GObjectController*>::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<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();
        }
        //=========================================================================
 
@@ -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;
        }
 
        //=========================================================================
index d7a4011f53530bd0a5bd3c28582da4a17fd08f1d..82c2052fc019088b46ccc983d2276c95ed5a13e0 100644 (file)
@@ -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();