]> Creatis software - bbtkGEditor.git/commitdiff
#3252Select mechanism of boxes
authorEduardo DAVILA <davila@creatis.insa-lyon.fr>
Tue, 20 Sep 2022 14:08:26 +0000 (16:08 +0200)
committerEduardo DAVILA <davila@creatis.insa-lyon.fr>
Tue, 20 Sep 2022 14:08:26 +0000 (16:08 +0200)
12 files changed:
lib/EditorGraphicBBS/bbsKernelEditorGraphic/GObjectModel.cxx
lib/EditorGraphicBBS/bbsKernelEditorGraphic/GObjectModel.h
lib/EditorGraphicBBS/bbsKernelEditorGraphic/GlobalConstants.h
lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBlackBoxController.cxx
lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBlackBoxController.h
lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBoxController.cxx
lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GObjectController.cxx
lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGObjectView.cxx
lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGObjectView.h
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.cxx
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.h

index e4b77adede5e31ea6d0fe31f81fa6853615a16ac..70c7ed4d892725c7acff9ea0e0d4ea8e581e58f5 100644 (file)
@@ -137,7 +137,6 @@ namespace bbtk
        }
 
        //=========================================================================
-
        bool GObjectModel::isPointInside(double x,double y, double z)//virtual
        {
                if(x>=_xInic && x<=_xFin && y<=_yInic && y>=_yFin)
@@ -150,8 +149,20 @@ namespace bbtk
                }
        }
 
-       //=========================================================================
 
+    //=========================================================================
+    bool GObjectModel::isBoxInsideRectangle(double x1,double y1, double z1,double x2,double y2, double z2)//virtual
+    {
+        if(_xInic>x1 && _xInic<x2 && _xFin>x1 && _xFin<x2 &&
+           _yInic>y1 && _yInic<y2 && _yFin>y1 && _yFin<y2  )
+        {
+            return true;
+        } else  {
+            return false;
+        }
+    }
+
+       //=========================================================================
        void GObjectModel::move(double xx,double yy,double zz)//virtual
        {
                setInicPoint(xx,yy,zz);
index ee639e33e579b4abf3b207bdd5ff755125418184..368b9775368667d61677ad56abd5981d2a01e63d 100644 (file)
@@ -108,6 +108,7 @@ namespace bbtk {
 
         // Returns true if (x,y,z) is inside the rectangle 
         virtual bool isPointInside( double x, double y, double z );
+        bool isBoxInsideRectangle(double x1,double y1, double z1,double x2,double y2, double z2);
 
         // Get the type of the graphical objects (See the GlobalConstants.h file)
         int getGObjectType( );
index bd274231795708303b368c7bcec329699a59d8ba..4d03701cffdbc10a951fc2309a93b6babfb0ce02 100644 (file)
@@ -113,6 +113,7 @@ namespace bbtk {
        const int DRAG_OBJECTS                          =       205;
        const int EDIT_BLACKBOX                         =       206;
        const int REMOVE_FROM_SELECTED          =       207;
+    const int SELECTING_BOXES           =   208;
 
 
        //// COLORS (object_state_(R|G|B))
index 095e70479ed8ac43cb225c5650093b2c2dba8e6d..3f2f83388e20cd74906f32544dbbcfb63aaaca78 100644 (file)
@@ -78,22 +78,19 @@ namespace bbtk
        GBlackBoxController::~GBlackBoxController()
        {
        }
-       //=========================================================================
 
+/*
+       //=========================================================================
        bool GBlackBoxController::OnMouseMove()
        {
-
                if ( _vtkInteractorStyleBaseView!=NULL)
                {
                        int X,Y;
                        crea::wxVTKRenderWindowInteractor *_wxVTKiren;
                        _wxVTKiren= _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
                        _wxVTKiren->GetEventPosition( X , Y );
-
                        int state  = _view->getState();
-
                        //Evaluate new state
-
                        if(state == NOTHING_HAPPENS)
                        {
                                if(_view->isPointInside(X,Y))
@@ -102,7 +99,6 @@ namespace bbtk
                                }
                                                return true; // to avoid to redraw all if nothing
                        } // state
-
                        if( state==HIGHLIGHTED)
                        {
                                if(!_view->isPointInside(X,Y))
@@ -110,67 +106,57 @@ namespace bbtk
                                        _view->setState(NOTHING_HAPPENS);
                                }
                        } // state
-
-
-                       if ((state==DRAG) && (_isLeftClickDown==true) )
-                       {
-                           _objHasBeenMoved=true;
-                       } // state
-
+//                     if ((state==DRAG) && (_isLeftClickDown==true) )
+//                     {
+//                         _objHasBeenMoved=true;
+//                     } // state
                        _model->notifyObservers(getId());
-
                }
                return true;
        }
+*/
 
        //=========================================================================
 
+/*
        bool GBlackBoxController::OnLeftButtonDown()
        {
-               _objHasBeenMoved = false;
+//             _objHasBeenMoved = false;
                _isLeftClickDown = true;
         bool ok=true;
-               
                int X,Y;
                crea::wxVTKRenderWindowInteractor *_wxVTKiren;
                _wxVTKiren= _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
                _wxVTKiren->GetEventPosition( X , Y );
-               
-               
-               
                int state  = _view->getState();
                //Evaluate new state
-               
                if(_view->isPointInside(X,Y))
-               
-//             if(state == HIGHLIGHTED)
-//EED3oct2010          if ( (state == HIGHLIGHTED) && (ctrlkey==1  ) )
-                       
-               if(state == SELECTED)
-               {
-                       _view->setState(NOTHING_HAPPENS);
-                       _model->notifyObservers(getId(),REMOVE_FROM_SELECTED);
-               } else {
-                   ok=false;
-                       _view->setState(SELECTED);
-                       _model->notifyObservers(getId(),ADD_TO_SELECTED);
-               }
-               
-               
+        {
+    //         if(state == HIGHLIGHTED)
+    //EED3oct2010              if ( (state == HIGHLIGHTED) && (ctrlkey==1  ) )
+            if(state == SELECTED)
+            {
+                _view->setState(NOTHING_HAPPENS);
+                _model->notifyObservers(getId(),REMOVE_FROM_SELECTED);
+            } else {
+                ok=false;
+                _view->setState(SELECTED);
+                _model->notifyObservers(getId(),ADD_TO_SELECTED);
+            }
+        } // EED 2022-09-16
                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);
                }
-
                return ok;
        }
+*/
 
+/*
        //=========================================================================
        bool GBlackBoxController::OnLeftButtonUp()
        {
@@ -187,6 +173,7 @@ namespace bbtk
 //             }
                return true;
        }
+*/
 
        //=========================================================================
        bool GBlackBoxController::OnRightButtonUp()
index c7a3a0141b7812c873616f4698df2a8b63b17fa8..4d41f75160517472a8f8f2143b22b87a654dcade 100644 (file)
@@ -79,43 +79,27 @@ Version:   $Revision$
 //Includes std
 #include <iostream>
 
-
 namespace bbtk
 {
-
        class GBlackBoxController : public GBoxController
        {
-
        public:
-
                //Constructors
                GBlackBoxController();
                ~GBlackBoxController();
-
                //Public methods
-
-
-
        private:
-
                //Attributes
-        bool _objHasBeenMoved;
-
+//        bool _objHasBeenMoved;
                //Private Methods
-
        protected:
-
                // Methods from InteractorStyleMaracas
-               virtual bool  OnMouseMove();
-               virtual bool  OnLeftButtonDown();
-               virtual bool  OnLeftButtonUp();
+//             virtual bool  OnMouseMove();
+//             virtual bool  OnLeftButtonDown();
+//             virtual bool  OnLeftButtonUp();
                virtual bool  OnMiddleButtonDown();
                virtual bool  OnRightButtonUp();
-
-
        };
-
-
 }
 // namespace bbtk
 #endif
index ad8024df98fa1cea91c0aba25213f0ebd705ba9d..ba87c386f5b6430d8d937386ac1ba8636591cb86 100644 (file)
@@ -80,20 +80,17 @@ namespace bbtk
        }
        //=========================================================================
 
+/*
        bool GBoxController::OnMouseMove()
        {
-
                if ( _vtkInteractorStyleBaseView!=NULL)
                {
                        int X,Y;
                        crea::wxVTKRenderWindowInteractor *_wxVTKiren;
                        _wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
                        _wxVTKiren->GetEventPosition( X , Y );
-
                        int state  = _view->getState();
-
                        //Evaluate new state
-
                        if(state == NOTHING_HAPPENS)
                        {
                                if(_view->isPointInside(X,Y))
@@ -108,31 +105,107 @@ namespace bbtk
                                        _view->setState(NOTHING_HAPPENS);
                                }
                        }
-
                        _model->notifyObservers(getId());
-
                }
                return true;
        }
+ */
+
+//=========================================================================
+bool GBoxController::OnMouseMove()
+{
+    if ( _vtkInteractorStyleBaseView!=NULL)
+    {
+        int X,Y;
+        crea::wxVTKRenderWindowInteractor *_wxVTKiren;
+        _wxVTKiren= _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
+        _wxVTKiren->GetEventPosition( X , Y );
+        int state  = _view->getState();
+        //Evaluate new state
+        if(state == NOTHING_HAPPENS)
+        {
+            if(_view->isPointInside(X,Y))
+            {
+                _view->setState(HIGHLIGHTED);
+            }
+                    return true; // to avoid to redraw all if nothing
+        } // state
+        if( state==HIGHLIGHTED)
+        {
+            if(!_view->isPointInside(X,Y))
+            {
+                _view->setState(NOTHING_HAPPENS);
+            }
+        } // state
+//            if ((state==DRAG) && (_isLeftClickDown==true) )
+//            {
+//                _objHasBeenMoved=true;
+//            } // state
+        _model->notifyObservers(getId());
+    }
+    return true;
+}
+
+
+
+
 
        //=========================================================================
 
+/*
        bool GBoxController::OnLeftButtonDown()
        {
            bool ok=true;
                int state  = _view->getState();
-
                //Evaluate new state
                if(state == HIGHLIGHTED)
                {
-                   ok=false;
-                       _isLeftClickDown=true;
+                   ok               = false;
+                       _isLeftClickDown = true;
                        _view->setState(SELECTED);
                        _model->notifyObservers(getId(),ADD_TO_SELECTED);
                }
                return ok;
-
        }
+*/
+
+bool GBoxController::OnLeftButtonDown()
+{
+//        _objHasBeenMoved = false;
+    _isLeftClickDown = true;
+    bool ok=true;
+    int X,Y;
+    crea::wxVTKRenderWindowInteractor *_wxVTKiren;
+    _wxVTKiren= _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
+    _wxVTKiren->GetEventPosition( X , Y );
+    int state  = _view->getState();
+    //Evaluate new state
+    if(_view->isPointInside(X,Y))
+    {
+//        if(state == HIGHLIGHTED)
+//EED3oct2010        if ( (state == HIGHLIGHTED) && (ctrlkey==1  ) )
+        if(state == SELECTED)
+        {
+            _view->setState(NOTHING_HAPPENS);
+            _model->notifyObservers(getId(),REMOVE_FROM_SELECTED);
+        } else {
+            ok=false;
+            _view->setState(SELECTED);
+            _model->notifyObservers(getId(),ADD_TO_SELECTED);
+        }
+    } // EED 2022-09-16
+    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);
+    }
+    return ok;
+}
+
+
 
        //=========================================================================
 
@@ -143,6 +216,7 @@ namespace bbtk
                wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
                wxVTKiren->GetEventPosition(X,Y);
 
+ /*
                int state  = _view->getState();
                //Evaluate new state
                if(_isLeftClickDown)
@@ -155,6 +229,7 @@ namespace bbtk
                                _model->notifyObservers(getId());
                        }
                }
+*/
        return true;
 
        }
index 19994d9505abc1818699ae6ac202687ed80861d8..55f011ce6d6e3f53d0db611446b373154e1ad93a 100644 (file)
@@ -87,36 +87,44 @@ namespace bbtk
 
     //=========================================================================
 
-    bool GObjectController::OnMouseMove( ) {
+    bool GObjectController::OnMouseMove( )
+    {
         int X , Y ;
         crea::wxVTKRenderWindowInteractor *_wxVTKiren ;
         _wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView( )->GetWxVTKRenderWindowInteractor( ) ;
         _wxVTKiren->GetEventPosition( X , Y ) ;
         int state = _view->getState( ) ;
 
-
         //Evaluate new state
-        if ( state == NOTHING_HAPPENS ) {
-            if ( _view->isPointInside( X , Y ) ) {
+        if ( state == NOTHING_HAPPENS )
+        {
+            if ( _view->isPointInside( X , Y ) )
+            {
                 _view->setState( HIGHLIGHTED ) ;
             }
         }
-        if ( state == HIGHLIGHTED ) {
-            if ( !_view->isPointInside( X , Y ) ) {
+        if ( state == HIGHLIGHTED )
+        {
+            if ( !_view->isPointInside( X , Y ) )
+            {
                 _view->setState( NOTHING_HAPPENS ) ;
             }
         }
 
         // JGRR & CM WH
 
-        if ( state == POSSIBLE_CONNECTION ) {
-            if ( _view->isPointInside( X , Y ) ) {
+        if ( state == POSSIBLE_CONNECTION )
+        {
+            if ( _view->isPointInside( X , Y ) )
+            {
                 _view->setState( SELECTED_POSSIBLE_CONNECTION ) ;
             }
         }
 
-        if ( state == SELECTED_POSSIBLE_CONNECTION ) {
-            if ( !_view->isPointInside( X , Y ) ) {
+        if ( state == SELECTED_POSSIBLE_CONNECTION )
+        {
+            if ( !_view->isPointInside( X , Y ) )
+            {
                 _view->setState( POSSIBLE_CONNECTION ) ;
             }
         }
index d9d784edee1c657624a76a68c3e8132972799aa5..d7306b76b0219a3dc6f63a47100c2d7a07bbf193 100644 (file)
@@ -140,6 +140,18 @@ namespace bbtk
                return _model->isPointInside(xx,yy,zz);
        }
 
+    //=========================================================================
+    bool vtkGObjectView::isBoxInsideRectangle(int X1,int Y1,  int  X2, int  Y2) //virtual
+    {
+        // RaC In the actual version, always z=GPOSITION_Z
+        double xx1=X1,yy1=Y1,zz1=GPOSITION_Z;
+        _baseView->TransCoordScreenToWorld(xx1,yy1,zz1);
+        double xx2=X2,yy2=Y2,zz2=GPOSITION_Z;
+        _baseView->TransCoordScreenToWorld(xx2,yy2,zz2);
+        
+        return _model->isBoxInsideRectangle(xx1,yy1,zz1, xx2,yy2,zz2 );
+    }
+
        //=========================================================================
        void vtkGObjectView::moveObject(int X,int Y) //virtual
        {               
index 5b096afd2b4fe0fc03ce50f6429c142b12035ab1..0ad49766d67aa04c6e9e3504e3d422085bba7500 100644 (file)
@@ -106,6 +106,8 @@ namespace bbtk
                // Method to force a vtk refresh to the list of controllers of the wxVtkBaseView
                void setRefreshWaiting();
                virtual bool isPointInside(int X,int Y);
+        virtual bool isBoxInsideRectangle(int X1,int Y1,  int  X2, int  Y2) ;
+
                virtual void moveObject(int X, int Y);
                virtual void removeFromScene();
                virtual void update(int idController,int command);              
index a75362f59584f70a50033233662ee85224d22eef..34125b66cdc49ed8a74151931ffe5c70ad93c277 100644 (file)
@@ -160,8 +160,8 @@ namespace bbtk
                      result = strtok( NULL, delims );
                      boxType += result;
               */
-           printf("EED wxGEditorTabPanel::OnDropText  <%s>  length %d %d \n", stdData.c_str(), stdData.length(), data.Len() ); 
-           printf("EED wxGEditorTabPanel::OnDropText  <%s>  wxString\n",(const char*)data.mb_str() ); 
+//         printf("EED wxGEditorTabPanel::OnDropText  <%s>  length %d %d \n", stdData.c_str(), stdData.length(), data.Len() );
+//         printf("EED wxGEditorTabPanel::OnDropText  <%s>  wxString\n",(const char*)data.mb_str() ); 
              if ( _panelsManager->TryToOpenScriptApplication(packageName,boxType) == false )
                {
                  _sceneManager->createGBlackBox(x,y,packageName, boxType);
index e839044db26271bb09997f39b5f2cf223433e148..1d8dc2957e68a4d5a5dbbbba61394369b4d00623 100644 (file)
@@ -110,6 +110,11 @@ wxVtkSceneManager::wxVtkSceneManager(wxGEditorTabPanel *parent, wxVtk3DBaseView
        }
        _idConnectionInCreation = -1;
        _contLastId                             = 0;
+    
+    selectRegionX1          = -1;
+    selectRegionY1          = -1;
+    selectRegionX2          = -1;
+    selectRegionY2          = -1;
 }
 
 //=========================================================================
@@ -251,29 +256,28 @@ std::string wxVtkSceneManager::generateANewNameForABox() {
 
 //=========================================================================
 
-std::string wxVtkSceneManager::findANewNameForABox() {
+std::string wxVtkSceneManager::findANewNameForABox()
+{
        std::string boxname = generateANewNameForABox();
-
-       while (boxExist(boxname) == true) {
+       while (boxExist(boxname) == true)
+    {
                boxname = generateANewNameForABox();
        } // while
-
        return boxname;
 }
 
 //=========================================================================
 void wxVtkSceneManager::configGBlackBox(int idBox, double xIn, double yIn,
                double zIn, std::string name, bool boxExecutable, double xEn,
-               double yEn, double zEn) {
+               double yEn, double zEn)
+{
        GObjectController *cont = _controllers[idBox];
        GBlackBoxModel *bbmod = (GBlackBoxModel*) cont->getModel();
        bbmod->setBBTKName(name);
        bbmod->setInicPoint(xIn, yIn, zIn);
        bbmod->setFinalPoint(xEn, yEn, zEn);
        bbmod->setExecutable(boxExecutable);
-
        bbmod->notifyObservers(_idManager);
-
 }
 
 //=========================================================================
@@ -831,16 +835,19 @@ bool wxVtkSceneManager::OnMouseMove()
 {
        int X, Y;
        bool okStatusMessage    = false;
-       bool okPortMessage      = false;
+       bool okPortMessage          = false;
        crea::wxVTKRenderWindowInteractor *wxVTKiren;
        wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
        wxVTKiren->GetEventPosition(X, Y);
 
-       if (_worldState == DRAG_OBJECTS) {
-               for (int i = 0; i < (int) _selectedObjects.size(); i++) {
+       if (_worldState == DRAG_OBJECTS)
+    {
+               for (int i = 0; i < (int) _selectedObjects.size(); i++)
+        {
                        int id = _selectedObjects[i];
                        GObjectController* cont = _controllers[id];
-                       if (_startDragging) {
+                       if (_startDragging)
+            {
                                cont->getView()->setStartDragging(true);
                        }
                        cont->getView()->moveObject(X, Y);
@@ -850,20 +857,23 @@ bool wxVtkSceneManager::OnMouseMove()
 
                std::map<int, GObjectController*>::iterator it;
 
-               for (it = _controllers.begin(); it != _controllers.end(); ++it) {
+               for (it = _controllers.begin(); it != _controllers.end(); ++it)
+        {
                        GObjectController *desc = it->second;
-                       if (desc->getGObjectType() == GCONNECTOR) {
+                       if (desc->getGObjectType() == GCONNECTOR)
+            {
                                vtkGConnectorView* vconn = (vtkGConnectorView*) desc->getView();
                                vconn->updateStartEndPoints();
-                       }
-               }
+                       } // if
+               } // for
 
                _startDragging = false;
 
        } else if (_worldState == NOTHING_HAPPENS || _worldState == INIT_CREATION_CONTOUR) {
                std::map<int, GObjectController*>::iterator it;
                double px, py, pz;
-               for (it = _controllers.begin(); it != _controllers.end(); ++it) {
+               for (it = _controllers.begin(); it != _controllers.end(); ++it)
+        {
                        GObjectController *desc = it->second;
                        int type        = desc->getGObjectType();
                        int state       = desc->getView()->getState();
@@ -912,12 +922,55 @@ bool wxVtkSceneManager::OnMouseMove()
                                                _bugTextActor_status= 2;
                                        } //  _bugTextActor_tex
                                        _bugTextActor_text                  = desc->getStatusText();
-
                                } // if GPORT
-                       }  //if state
+            } // if  state
                } // for controllers it
-       }
-       if (okStatusMessage == false) 
+    } else if (_worldState == SELECTING_BOXES ) {
+
+
+        int sX1,sX2,sY1,sY2;
+        if (X<selectRegionX1)
+        {
+            sX1=X; sX2=selectRegionX1;
+        } else {
+            sX1=selectRegionX1; sX2=X;
+        }
+
+        if (Y<selectRegionY1)
+        {
+            sY1=Y; sY2=selectRegionY1;
+        } else {
+            sY1=selectRegionY1; sY2=Y;
+        }
+
+        UnSelectBlackBoxes();
+        
+        std::map<int, GObjectController*>::iterator it;
+        GObjectController                           *desc;
+        int                                         type;
+        int                                         state;
+        int                                         id;
+        for (it = _controllers.begin(); it != _controllers.end(); ++it)
+        {
+            desc    = it->second;
+            type    = desc->getGObjectType();
+            state   = desc->getView()->getState();
+            
+            if ( (type==GBLACKBOX) || (type==GCOMPLEXINPUTPORT) || (type==GCOMPLEXOUTPUTPORT) )
+            {
+                if ( desc->getView()->isBoxInsideRectangle( sX1 , sY1,sX2 , sY2 ) )
+                {
+                    desc->getView()->setState(SELECTED);
+                    id = desc->getModel()->getObjectId();
+                    desc->getModel()->notifyObservers( id , ADD_TO_SELECTED );
+                }
+            } // if type == 1
+        } // for
+        
+        
+    } //  if _worldState
+    
+       if (okStatusMessage == false)
        {
                updateStatusBar("");
        }
@@ -961,42 +1014,49 @@ bool wxVtkSceneManager::OnLeftButtonDown()
 
                        } // if
                } // for
-
                if (isOverPort == false) 
                {
                        CancelConnection();
                        UnSelectBlackBoxes();
                } // isOverPort
-       
-
        } else { //_worldState
-
-               _worldState             = DRAG_OBJECTS;
-               _startDragging  = true;
-
-               int shiftkey    = _vtkInteractorStyleBaseView->GetInteractor()->GetShiftKey();
-               int ctrlkey             = _vtkInteractorStyleBaseView->GetInteractor()->GetControlKey();
-               ctrlkey                 = ctrlkey + shiftkey;
-
-               GObjectController *cont = GetGBlackBoxControlerPointedByMouse();
-
-               if (cont != NULL) {
+               _startDragging          = true;
+               int shiftkey            = _vtkInteractorStyleBaseView->GetInteractor()->GetShiftKey();
+               int ctrlkey                     = _vtkInteractorStyleBaseView->GetInteractor()->GetControlKey();
+               ctrlkey                         = ctrlkey + shiftkey;
+               GObjectController *cont = GetGBoxControlerPointedByMouse();
+               if (cont != NULL)
+        {
+            _worldState        = DRAG_OBJECTS;
                        int state = cont->getView()->getState();
-                       if ((ctrlkey == 0) && (state == HIGHLIGHTED)) {
+                       if ((ctrlkey == 0) && (state == HIGHLIGHTED))
+            {
                                UnSelectBlackBoxes();
-                       }
+                       } // if ctrlkey state
                } else {
                        UnSelectBlackBoxes();  // EED 12/07/2012
-               }
-               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
-       } // if _selectedObjects.size
-
+            _worldState        = SELECTING_BOXES;
+               } // if cont
+        
+        if (_worldState==SELECTING_BOXES)
+        {
+            crea::wxVTKRenderWindowInteractor *wxVTKiren;
+            wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
+            wxVTKiren->GetEventPosition(selectRegionX1, selectRegionY1);
+        } // if _worldState SELECTING_BOXES
+        
+        if (_worldState==DRAG_OBJECTS)
+        {
+            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
+        } // if  _worldState DRAG_OBJECTS
 
+       } // if _selectedObjects.size
        return true;
 }
 
@@ -1004,10 +1064,11 @@ bool wxVtkSceneManager::OnLeftButtonDown()
 
 bool wxVtkSceneManager::OnLeftButtonUp() 
 {
-       if (_worldState == DRAG_OBJECTS) {
+       if ( (_worldState == DRAG_OBJECTS) || (_worldState == SELECTING_BOXES) )
+    {
                _worldState = NOTHING_HAPPENS;
-
-               for (int i = 0; i < (int) _selectedObjects.size(); i++) {
+               for (int i = 0; i < (int) _selectedObjects.size(); i++)
+        {
                        int id = _selectedObjects[i];
                        GObjectController* cont = _controllers[id];
                        cont->getView()->setState(SELECTED);
@@ -1043,7 +1104,6 @@ void wxVtkSceneManager::CancelConnection()
 }
 
 //=========================================================================
-
 bool wxVtkSceneManager::OnRightButtonUp() 
 {
        if (_worldState == INIT_CREATION_CONTOUR) 
@@ -1055,43 +1115,37 @@ bool wxVtkSceneManager::OnRightButtonUp()
 }
 
  ///JLGR 21-05-2012
-
-bool wxVtkSceneManager::OnMiddleButtonDown() {
-
-
+//=========================================================================
+bool wxVtkSceneManager::OnMiddleButtonDown()
+{
         this->_vtkInteractorStyleBaseView->StartPan();
-
         return true;
-    }
-
-bool wxVtkSceneManager::OnMiddleButtonUp() {
-
+}
 
+//=========================================================================
+bool wxVtkSceneManager::OnMiddleButtonUp()
+{
         this->_vtkInteractorStyleBaseView->EndPan();
-
-
         return true;
-    }
-
+}
 
 //=========================================================================
-
-GObjectController *wxVtkSceneManager::GetGBlackBoxControlerPointedByMouse() {
+GObjectController *wxVtkSceneManager::GetGBoxControlerPointedByMouse()
+{
        GObjectController *result = NULL;
        int X, Y;
        crea::wxVTKRenderWindowInteractor *wxVTKiren;
-       wxVTKiren
-                       = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
+       wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
        wxVTKiren->GetEventPosition(X, Y);
-
        std::map<int, GObjectController*>::iterator it;
-
-       for (it = _controllers.begin(); it != _controllers.end(); ++it) {
+       for (it = _controllers.begin(); it != _controllers.end(); ++it)
+    {
                GObjectController *cont = it->second;
                int type = cont->getGObjectType();
-
-               if (cont->getView()->isPointInside(X, Y) == true) {
-                       if (type == GBLACKBOX) {
+               if (cont->getView()->isPointInside(X, Y) == true)
+        {
+                       if ( (type == GBLACKBOX) ||  (type == GCOMPLEXINPUTPORT) || (type == GCOMPLEXOUTPUTPORT))
+            {
                                result = cont;
                        } // if type
                } // if isPointInside
@@ -1100,8 +1154,10 @@ GObjectController *wxVtkSceneManager::GetGBlackBoxControlerPointedByMouse() {
 }
 
 //=========================================================================
-void wxVtkSceneManager::UnSelectBlackBoxes() {
-       for (int i = 0; i < (int) _selectedObjects.size(); i++) {
+void wxVtkSceneManager::UnSelectBlackBoxes()
+{
+       for (int i = 0; i < (int) _selectedObjects.size(); i++)
+    {
                int id = _selectedObjects[i];
                GObjectController* control = _controllers[id];
                control->getView()->setState(NOTHING_HAPPENS);
@@ -1111,41 +1167,40 @@ void wxVtkSceneManager::UnSelectBlackBoxes() {
 }
 
 //=========================================================================
-bool wxVtkSceneManager::OnLeftDClick() {
-       GObjectController *cont = GetGBlackBoxControlerPointedByMouse();
-       if (cont != NULL) {
-               UnSelectBlackBoxes();
-               _parent->editBlackBox((GBlackBoxModel*) cont->getModel());
-       }
+bool wxVtkSceneManager::OnLeftDClick()
+{
+       GObjectController *cont = GetGBoxControlerPointedByMouse();
+       if (cont != NULL)
+    {
+        int type    = cont->getGObjectType();
+        if (type==GBLACKBOX)
+        {
+            UnSelectBlackBoxes();
+            _parent->editBlackBox((GBlackBoxModel*) cont->getModel());
+        } // if type
+       } // if cont
        return true;
 }
 
 //=========================================================================
-
 bool wxVtkSceneManager::OnChar() 
 {
        bool ok=false;
        bool oktmp;
        char keyCode    = _vtkInteractorStyleBaseView->GetInteractor()-> GetKeyCode();
-       int ctrlkey             = _vtkInteractorStyleBaseView->GetInteractor()->GetControlKey();
-        
+       int  ctrlkey            = _vtkInteractorStyleBaseView->GetInteractor()->GetControlKey();
        // KeyCode 127 : Delete Key
        // KeyCode 8 : Backspace Key
-
-
        if (keyCode == 8 || keyCode == 127 || keyCode == 27) 
        {
                if (_worldState == INIT_CREATION_CONTOUR) 
                {
                        CancelConnection();
-                       UnSelectBlackBoxes();
-               }
+            UnSelectBlackBoxes();
+               } // if _worldState
        }
-
-
        if (keyCode == 8 || keyCode == 127) 
        {
-
                        for (int i = 0; i < (int) _selectedObjects.size(); i++) 
                        {
                                int id = _selectedObjects[i];
@@ -1160,7 +1215,6 @@ bool wxVtkSceneManager::OnChar()
                        if (ok) _selectedObjects.clear();
                        _parent->saveTempandUpdate("delete object");
        }// if keyCode
-       
        // Duplicate
        ctrlkey+=keyCode;
        if(ctrlkey==5){                
@@ -1174,28 +1228,26 @@ bool wxVtkSceneManager::OnChar()
                }else{
                        std::cout<<"No objects to copy\n";
                } // _selectedObjects.size
-       } // ctrlkey 5  
-
+       } // ctrlkey 5
        return true;
 }
 
 //=========================================================================
-
-void wxVtkSceneManager::AddControlerToBeRemove(
-               std::vector<int> *controllersToRemove, int id) {
-
+void wxVtkSceneManager::AddControlerToBeRemove( std::vector<int> *controllersToRemove, int id)
+{
        int i;
        bool ok = true;
-       for (i = 0; i < (int) controllersToRemove->size(); i++) {
-               if (id == (*controllersToRemove)[i]) {
+       for (i = 0; i < (int) controllersToRemove->size(); i++)
+    {
+               if (id == (*controllersToRemove)[i])
+        {
                        ok = false;
-               }
-       }
-
-       if (ok == true) {
+               } // if  id
+       } //  for i
+       if (ok == true)
+    {
                controllersToRemove->push_back(id);
-       }
-
+       } //if ok
 }
 
 //=========================================================================
index c5cb8cbf591157234be8279bbd8e3e8c3614883e..be2519ed5d5487c9525d0e68d656b91aa570a62f 100644 (file)
@@ -290,8 +290,14 @@ namespace bbtk
         std::string LineNumber(bool withLineNumber, int &value);
         int GetIndexInSelected(int idControler);
         void UnSelectBlackBoxes();
-        GObjectController *GetGBlackBoxControlerPointedByMouse();
+        GObjectController *GetGBoxControlerPointedByMouse();
                void CancelConnection();
+        
+        int selectRegionX1;
+        int selectRegionY1;
+        int selectRegionX2;
+        int selectRegionY2;
+
        protected:
        };