]> Creatis software - bbtkGEditor.git/commitdiff
Move box and refresh position ... ports don't refresh automatically their position...
authorcorredor <>
Tue, 6 Apr 2010 15:21:55 +0000 (15:21 +0000)
committercorredor <>
Tue, 6 Apr 2010 15:21:55 +0000 (15:21 +0000)
Good and sunny day

24 files changed:
lib/EditorGraphicBBS/bbsKernelEditorGraphic/GBlackBoxModel.cxx
lib/EditorGraphicBBS/bbsKernelEditorGraphic/GBlackBoxModel.h
lib/EditorGraphicBBS/bbsKernelEditorGraphic/GObjectModel.cxx
lib/EditorGraphicBBS/bbsKernelEditorGraphic/GObjectModel.h
lib/EditorGraphicBBS/bbsKernelEditorGraphic/GPortModel.cxx
lib/EditorGraphicBBS/bbsKernelEditorGraphic/GPortModel.h
lib/EditorGraphicBBS/bbsKernelEditorGraphic/GlobalConstants.h
lib/EditorGraphicBBS/bbsKernelEditorGraphic/Observable.cxx
lib/EditorGraphicBBS/bbsKernelEditorGraphic/Observable.h
lib/EditorGraphicBBS/bbsKernelEditorGraphic/Observer.cxx
lib/EditorGraphicBBS/bbsKernelEditorGraphic/Observer.h
lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.cxx
lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.h
lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GObjectController.cxx
lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GObjectController.h
lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GObjectsMVCFactory.cxx
lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GPortController.cxx
lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GPortController.h
lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGBlackBoxView.cxx
lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGBlackBoxView.h
lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGObjectView.cxx
lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGObjectView.h
lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGPortView.cxx
lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGPortView.h

index 2a2081f463a1bec9826708452acaf87bfa475fc0..f2866f599afa50e52256b0458ae34be28f6ac38e 100644 (file)
@@ -89,6 +89,43 @@ namespace bbtk
 
        //=========================================================================
 
+       void GBlackBoxModel::move(double xx,double yy,double zz)
+       {
+               setInicPoint(xx,yy,zz);
+               //std::cout<<"GBlackBoxModel::move xx:"<<xx<<" yy:"<<yy<<" zz:"<<zz<<std::endl;
+
+               //Refresh inputs position
+               int i;
+               for(i=0;i<_inputs.size();i++)
+               {
+                       _inputs[i]->updatePortPosition(i);
+               }
+               
+               //Refresh outputs position
+               for(i=0;i<_outputs.size();i++)
+               {
+                       _outputs[i]->updatePortPosition(i);
+               }
+
+       }
+       
+       //=========================================================================
+
+       GPortModel* GBlackBoxModel::getStartInputPort()
+       {
+               GPortModel* temp = NULL;
+
+               for(int i=0; i<_inputs.size() && temp == NULL;i++)
+               {
+                       if(_inputs[i]->getState() == CREATING_CONTOUR)
+                       {
+                               temp = _inputs[i];
+                       }
+               }
+
+               return temp;
+       }
+
 }  // EO namespace bbtk
 
 // EOF
index 5536e00a5104b1e37b9a6e8a3bd3295c3f3dd893..f1c36cf6030daf603e07b8d15209c24e1f9a711d 100644 (file)
@@ -46,6 +46,7 @@ Version:   $Revision$
 //Includes same project
 #include "GlobalConstants.h"
 #include "GObjectModel.h"
+#include "GPortModel.h"
 
 //Includes creaMaracasVisu
 
@@ -73,6 +74,8 @@ namespace bbtk
                void addOutputPort(GPortModel *outputport);
                int getNumInputPorts();
                int getNumOutputPorts();
+               virtual void move(double xx,double yy,double zz);
+               GPortModel* getStartInputPort();
 
 
        private:
index 4752ec9595d6414bc1adc71812582e7d6e081e45..f6d8c4d174da9f0fedebfdf3c5806166893797f4 100644 (file)
@@ -140,6 +140,10 @@ namespace bbtk
 
        //=========================================================================
 
+       void GObjectModel::move(double xx,double yy,double zz)//virtual
+       {
+               setInicPoint(xx,yy,zz);
+       }
 
        //=========================================================================
 
index 4dfc47791b056f24e89dd10f7a979b6506d86302..b610386018001a98279f611c60d20d0e0fb226a2 100644 (file)
@@ -75,6 +75,7 @@ namespace bbtk
                virtual void setFinalPoint(double& x, double& y, double& z);
                void setState(int state);
                int getState();
+               virtual void move(double xx,double yy,double zz);
 
                virtual bool isPointInside(double x,double y, double z);
                virtual void updateBlackBox(BlackBoxDescriptor::Pointer descriptor);
@@ -82,6 +83,7 @@ namespace bbtk
                int getGObjectType();
                void setGObjectType(int obtype);
                
+               
        private:
 
                //Private Attributes
index 82940f85e46ccaaf298f4105c668b016cd819bf2..abb6945db8c7bc903b5a513c5a5951570f06424d 100644 (file)
@@ -53,40 +53,54 @@ namespace bbtk
        }
        //=========================================================================
 
-       void GPortModel::registerInBox(GBlackBoxModel *blackBox,int portType)
+       void GPortModel::registerInBox(GBlackBoxModel *blackBox,int portType, int pos)
        {
                _parentBox = blackBox;
                _portType = portType;
 
+               updatePortPosition(pos);
+
+       }
+
+       //=========================================================================
+
+       void GPortModel::updatePortPosition(int pos)
+       {
                double xInic, yInic,zInic,xFin,yFin,zFin;
                _parentBox->getInicPoint(xInic,yInic,zInic);
                _parentBox->getFinalPoint(xFin, yFin,zFin);
-               
-               int cant = 0;
+
                double posX=xInic,posY=yInic,posZ=zInic;
                if(_portType==GOUTPUTPORT)
                {
-                       cant = _parentBox->getNumOutputPorts();
                        posY = yInic+PORT_HEIGHT;
                }
                else if(_portType==GINPUTPORT)
                {
-                       cant = _parentBox->getNumInputPorts();
                        posY = yFin;
                }
 
-               posX = xInic + PORT_WIDTH + cant*2*PORT_WIDTH;
+               //Usually pos begins in 0
+               posX = xInic + PORT_WIDTH + pos*2*PORT_WIDTH;
                
                setInicPoint(posX,posY,posZ);
 
                posX=posX+PORT_WIDTH;
                posY=posY-PORT_HEIGHT;
 
-               setFinalPoint(posX,posY,posZ);
-
+               setFinalPoint(posX,posY,posZ);          
+               
+               setChanged();
+               notifyObservers();
        }
 
        //=========================================================================
+
+       int GPortModel::getPortType()
+       {
+               return _portType;
+       }
+
 }  // EO namespace bbtk
 
 // EOF
index 1d6fa3e47e0f52ac251d0a638b079a27d2208b8d..1a32e09cee6d3865c676cc04c920ccb9afc613b2 100644 (file)
@@ -69,7 +69,10 @@ namespace bbtk
                ~GPortModel();
                
                //Public methods                
-               void registerInBox(GBlackBoxModel *blackBox,int portType);
+               void registerInBox(GBlackBoxModel *blackBox,int portType, int pos);
+               void updatePortPosition(int pos);
+               int getPortType();
+
        private:
 
                //Attributes
index 112822f745bfab71fa4ff382becb58cacbc8a3cb..2beacdbf88add1d6b93be550707b191e1f9a1c7e 100644 (file)
@@ -51,11 +51,12 @@ namespace bbtk
        const int GOUTPUTPORT = 5;
 
        // Object states
-       static const int NOTHING_HAPPENS = 101;
+       const int NOTHING_HAPPENS = 101;
        const int HIGHLIGHTED=102;
        const int CLICKED=103;
        const int DRAG=104;
        const int SELECTED=105;
+       const int CREATING_CONTOUR=106;
 
        // Object dimensions
        const double BOX_HEIGHT=0.1;
@@ -63,6 +64,10 @@ namespace bbtk
        const double PORT_HEIGHT=0.04;
        const double PORT_WIDTH=0.04;
 
+       // Commands
+       const int REPAINT = 201;
+       const int INIT_CREATION_CONTOUR= 202;
+       
        // Colors (object_state_(R|G|B))
        const double BOXCONTOUR_NH_R=0.0;
        const double BOXCONTOUR_NH_G=0.0;
index 9b6a4f5622804528a8cb1f9b99735de67545e084..b169cc43b0e737cd74a3646d680b1d293d4959a7 100644 (file)
@@ -59,14 +59,14 @@ namespace bbtk
 
        //=========================================================================
        
-       void Observable::notifyObservers()
+       void Observable::notifyObservers(int command)
        {
                if(_changed)
                {
                        int i;
                        for(i=0;i<_observers.size();i++)
                        {
-                               _observers[i]->update();
+                               _observers[i]->update(command);
                        }
                        _changed=false;
                }
index 72e1e80cb6b50b8f6c4f30daae39d4660b57ac70..a55b17de2f01fead3dbf9a05a6afda2eb1df143c 100644 (file)
@@ -47,6 +47,9 @@ Version:   $Revision$
 
 #include "Observer.h"
 
+//Includes same project
+#include "GlobalConstants.h"
+
 //Includes std
 #include <iostream>
 #include <vector>
@@ -68,7 +71,7 @@ namespace bbtk
 
                bool hasChanged();
 
-               void notifyObservers();
+               void notifyObservers(int command=REPAINT);
                     
                void setChanged();
 
index 3be8382c7053b59944597b818f5463f1e3ba1387..d80b07d74a2bae14eba94be65ff52812f377cafe 100644 (file)
@@ -36,6 +36,7 @@ Version:   $Revision$
 
 #include "Observer.h"
 
+
 namespace bbtk
 {
 
@@ -51,7 +52,7 @@ namespace bbtk
        }
        //=========================================================================
 
-       void Observer::update() //virtual
+       void Observer::update(int command) //virtual
        {
                //virtual
        }
index ac8ad9e01b22682b1b27446f8b0872071fe7088f..bd0e34560f9772dc8e1e81136cd5ae65f680bad3 100644 (file)
@@ -59,7 +59,7 @@ namespace bbtk
                ~Observer();
                
                //Public methods
-               virtual void update();
+               virtual void update(int command);
                
                
        private:
index bbe321e5195144670282d474a359aaf0a5c1a2bb..3c79b612fdb903cd3395cce040e00b83d389ba1d 100644 (file)
@@ -55,6 +55,9 @@ namespace bbtk
                        ///// ******* TO ERASE *******
                        //JUST TO TEST
                        //
+                       
+                       
+                       
                        vtkConeSource *cone = vtkConeSource::New();
        
                   cone->SetResolution(10);
@@ -93,6 +96,8 @@ namespace bbtk
                        _pointVtkActor->SetMapper(_bboxMapper);
 
                        getRenderer()->AddActor(_pointVtkActor);
+
+                       
                        
                        // ******* TO ERASE *******
                        /////////////////////
@@ -160,27 +165,30 @@ namespace bbtk
                model->setInicPoint(xx,yy,zz);
                
                model->addObserver(view);
+               model->addObserver(this);
 
                //Iterate and create the input ports
                std::map<std::string, BlackBoxInputDescriptor*> descriptorInMap = descriptor->GetInputDescriptorMap();
                std::map<std::string, BlackBoxInputDescriptor*>::iterator itInput;
 
+               int i=0;
                for(itInput = descriptorInMap.begin(); itInput != descriptorInMap.end(); ++itInput)
                {
                        BlackBoxInputDescriptor *desc = itInput->second;
-                       createGInputPort(desc,model);
+                       createGInputPort(desc,model,i);
+                       i++;
                }
 
                //Iterate and create the output ports
                std::map<std::string, BlackBoxOutputDescriptor*> descriptorOutMap = descriptor->GetOutputDescriptorMap();
                std::map<std::string, BlackBoxOutputDescriptor*>::iterator itOutput;
 
-
+               i=0;
                for(itOutput = descriptorOutMap.begin();itOutput != descriptorOutMap.end(); ++itOutput)
                {
                        BlackBoxOutputDescriptor *desc = itOutput->second;
-                       createGOutputPort(desc,model);
-                       
+                       createGOutputPort(desc,model,i);
+                       i++;
                }
 
 
@@ -201,13 +209,13 @@ namespace bbtk
                registerController((InteractorStyleMaracas*) controller);
 
                //Add the object to the objects list (only boxes and connectors)
-               objects.push_back(model);
+               _objects.push_back(model);
 
        }
 
        //=========================================================================
 
-       void wxVtkSceneManager::createGOutputPort(BlackBoxOutputDescriptor *desc,GBlackBoxModel *blackBox)
+       void wxVtkSceneManager::createGOutputPort(BlackBoxOutputDescriptor *desc,GBlackBoxModel *blackBox, int pos)
        {
                int type = GPORT;
 
@@ -216,9 +224,12 @@ namespace bbtk
                vtkGObjectView *view = GObjectsMVCFactory::getInstance()->createGObjectView(type);
                GObjectController* controller = GObjectsMVCFactory::getInstance()->createGObjectController(type);
 
-               model->registerInBox(blackBox,GOUTPUTPORT);
+               model->registerInBox(blackBox,GOUTPUTPORT, pos);
                blackBox->addOutputPort(model);
                
+               model->addObserver(view);
+               model->addObserver(this);
+
                //Associates the view with the correspondent renderer and the  model.
                //(NOTE: Refresh is only made by the view)
                view->setModel(model);
@@ -234,7 +245,7 @@ namespace bbtk
 
        //=========================================================================
 
-       void wxVtkSceneManager::createGInputPort(BlackBoxInputDescriptor *desc,GBlackBoxModel *blackBox)
+       void wxVtkSceneManager::createGInputPort(BlackBoxInputDescriptor *desc,GBlackBoxModel *blackBox, int pos)
        {
                int type = GPORT;
 
@@ -243,9 +254,11 @@ namespace bbtk
                vtkGObjectView *view = GObjectsMVCFactory::getInstance()->createGObjectView(type);
                GObjectController* controller = GObjectsMVCFactory::getInstance()->createGObjectController(type);
 
-               model->registerInBox(blackBox,GINPUTPORT);
+               model->registerInBox(blackBox,GINPUTPORT,pos);
                blackBox->addInputPort(model);
 
+               model->addObserver(view);
+               model->addObserver(this);
 
                //Associates the view with the correspondent renderer and the  model.
                //(NOTE: Refresh is only made by the view)
@@ -262,6 +275,39 @@ namespace bbtk
 
        //=========================================================================
 
+       void wxVtkSceneManager::createGConnector(GPortModel* startPort)
+       {
+               manualContourControler* manContourControl       = new manualContourControler();
+               manualViewContour* manViewerContour     = new manualViewContour();
+               manualContourModel* manContourModel     = new manualContourModel();
+
+               
+               manViewerContour->SetModel( manContourModel );
+               manViewerContour->SetWxVtkBaseView( _baseView );
+               manViewerContour->SetRange( 0.5 );
+               manViewerContour->SetZ( 900 );
+
+               manViewerContour->SetColorNormalContour(0, 0, 1);
+               manViewerContour->SetColorEditContour(0.5, 0.5, 0.5);
+               manViewerContour->SetColorSelectContour(1, 0.8, 0);
+               manViewerContour->SetWidthLine(1);
+
+               manContourControl->SetModelView( manContourModel , manViewerContour );
+               manContourControl->Configure();
+               int i,sizeLstPoints = manContourModel->GetSizeLstPoints();
+               for ( i=0; i<sizeLstPoints; i++ )
+               {
+                       manViewerContour->AddPoint();
+               }
+
+               manContourControl->CreateNewManualContour();
+               manViewerContour->RefreshContour();                     
+               registerController((InteractorStyleMaracas*) manContourControl);
+
+       }
+
+       //=========================================================================
+
        void wxVtkSceneManager::registerController(InteractorStyleMaracas *param)
        {
                vtkInteractorStyleBaseView* baseViewControlManager = (vtkInteractorStyleBaseView*)_baseView->GetInteractorStyleBaseView();
@@ -287,7 +333,36 @@ namespace bbtk
        {
                return true;
        }
+
        //=========================================================================
+       
+       void wxVtkSceneManager::update(int command)
+       {
+               
+               if(command==INIT_CREATION_CONTOUR)
+               {
+                       std::cout<<"wxVtkSceneManager::update size:"<<_objects.size()<<std::endl;
+                       for(int i = 0; i<_objects.size();i++)
+                       {
+                               std::cout<<"wxVtkSceneManager::update type:"<<_objects[i]->getGObjectType()<<std::endl;
+                               if(_objects[i]->getGObjectType() == GBLACKBOX)
+                               {
+                                       
+                                       GPortModel* startInputPort=((GBlackBoxModel*)_objects[i])->getStartInputPort();
+                                       std::cout<<"wxVtkSceneManager::update "<<startInputPort<<std::endl;
+                                       createGConnector(startInputPort);
+
+                               }
+                               else
+                               {
+                                       // The others must not react to events
+                               }
+                       }
+               }
+       }
+
+       //=========================================================================
+
 }  // EO namespace bbtk
 
 // EOF
index db78193a2eebe90dc04f5a5ef0c73ff95595acde..55343688793515d83555e59cd9af5b0a028a567c 100644 (file)
@@ -45,6 +45,8 @@ Version:   $Revision$
 
 //Includes same project
 #include "GObjectsMVCFactory.h"
+#include "Observer.h"
+#include "GPortModel.h"
 
 //Includes bbtk
 #include <bbtkBlackBoxInputDescriptor.h>
@@ -54,6 +56,9 @@ Version:   $Revision$
 #include <wxVtk3DBaseView.h>
 #include <InteractorStyleMaracas.h>
 #include <vtkInteractorStyleBaseView2D.h>
+#include <manualContourControler.h>
+#include <manualViewContour.h>
+#include <manualContourModel.h>
 
 //Includes vtk
 #include <vtkRenderWindow.h>
@@ -69,7 +74,7 @@ Version:   $Revision$
 namespace bbtk
 {
 
-       class wxVtkSceneManager : public InteractorStyleMaracas 
+       class wxVtkSceneManager : public InteractorStyleMaracas , public Observer
        {
        public: 
                wxVtkSceneManager(wxDropTarget *parent, wxVtk3DBaseView *baseView, int id);
@@ -77,23 +82,28 @@ namespace bbtk
 
                void configureBaseView();
                void createGBlackBox(int x, int y,std::string packageName, std::string boxName);
-               void createGInputPort(BlackBoxInputDescriptor *desc,GBlackBoxModel *blackBox);
-               void createGOutputPort(BlackBoxOutputDescriptor *desc,GBlackBoxModel *blackBox);
+               void createGInputPort(BlackBoxInputDescriptor *desc,GBlackBoxModel *blackBox, int pos);
+               void createGOutputPort(BlackBoxOutputDescriptor *desc,GBlackBoxModel *blackBox, int pos);
+               void createGConnector(GPortModel* startPort);
+
                void registerController(InteractorStyleMaracas *param);
 
                vtkRenderWindow* getRenderWindow();
                vtkRenderer* getRenderer();
+
                void disconnectDrop();
+               
                virtual bool OnMouseMove();
 
+               virtual void update(int command);
                
        private:
 
                int _id;
                wxVtk3DBaseView *_baseView;
 
-               std::vector<GObjectModel*> objects;
-               std::vector<GObjectModel*> selectedObjects;
+               std::vector<GObjectModel*> _objects;
+               std::vector<GObjectModel*> _selectedObjects;
 
        protected:
 
index b053cbac0f419623328def98691cb4ff3bb0d86e..37b5de2d4ddf64067a6ed54e61cfe219614723e3 100644 (file)
@@ -74,8 +74,8 @@ bool GObjectController::OnMouseMove()
                //Evaluate new state
                if(!_model->hasChanged() && state == DRAG)
                {
-                       //MoveObject(X,Y);
-                       
+                       moveObject(X,Y);
+                       _model->setChanged();
                }
 
                if(!_model->hasChanged() && state == NOTHING_HAPPENS)
@@ -115,6 +115,7 @@ bool GObjectController::OnLeftButtonDown()
                //Evaluate new state
                if(!_model->hasChanged() && state==HIGHLIGHTED)
                {
+                       _view->isFirstDragging(true);
                        _model->setState(DRAG);
                        _model->setChanged();
                }
@@ -123,6 +124,7 @@ bool GObjectController::OnLeftButtonDown()
                {
                        if(_view->isPointInside(X,Y))
                        {
+                               _view->isFirstDragging(true);
                                _model->setState(DRAG);
                                _model->setChanged();
                        }       
@@ -199,8 +201,15 @@ bool GObjectController::OnRightButtonDown()
        }
        return true;
 }
+
 //=========================================================================
 
+void GObjectController::moveObject(int X,int Y)
+{
+       _view->moveObject(X,Y); 
+}
+
+//=========================================================================
 
 }  // EO namespace bbtk
 
index 45dd9ec5a4e1094079aed55066c09fdbfe5acedb..a490e635007d4b7c0c6c9342bda14909021d459e 100644 (file)
@@ -73,8 +73,7 @@ namespace bbtk
        private:
 
                //Attributes
-               GObjectModel* _model;
-               vtkGObjectView* _view;
+               
                
 
                //Private Methods
@@ -82,7 +81,8 @@ namespace bbtk
        protected:
 
                //Protected Attributes 
-
+               GObjectModel* _model;
+               vtkGObjectView* _view;
 
                //Protected Methods
                virtual bool  OnMouseMove();
@@ -91,6 +91,8 @@ namespace bbtk
                virtual bool  OnLeftDClick();
                virtual bool  OnRightButtonDown();
 
+               virtual void moveObject(int X,int Y);
+
        };
 
 
index 2cb11bed59e3454ba5494509dc056c7817c64695..c9a1bc9a1bde6c2bb672b05f83775bcfab2204d4 100644 (file)
@@ -130,6 +130,9 @@ namespace bbtk
                {
                        model = new GPortModel();
                }
+
+               model->setGObjectType(type);
+
                return model;
        }
 
index 33794ce4468e1b054701803e7ec7ee2ea7cd9e5a..c9c196b2ad776da0d7103006618c9234291cd4f0 100644 (file)
@@ -52,6 +52,65 @@ namespace bbtk
        }
        //=========================================================================
 
+       bool GPortController::OnLeftButtonDown()
+       {
+               
+               if ( _vtkInteractorStyleBaseView!=NULL )
+               {
+                       int X,Y;
+                       wxVTKRenderWindowInteractor *wxVTKiren;
+                       wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
+                       wxVTKiren->GetEventPosition(X,Y);
+
+                       int state  = _model->getState();
+                       
+                       int portType = ((GPortModel*)_model)->getPortType();
+
+                       //Evaluate new state
+                       if(!_model->hasChanged() && state==HIGHLIGHTED && portType==GINPUTPORT )
+                       {
+                               _model->setState(CREATING_CONTOUR);
+                               _model->setChanged();
+                       }
+
+                       _model->notifyObservers();
+
+               }
+               return true;
+       }
+       //=========================================================================
+       bool GPortController::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==CREATING_CONTOUR)
+                       {
+                               if(_view->isPointInside(X,Y))
+                               {
+                                       _model->setChanged();
+                                       _model->notifyObservers(INIT_CREATION_CONTOUR);
+                               }
+                               else
+                               {
+                                       _model->setState(NOTHING_HAPPENS);
+                                       _model->setChanged();
+                                       _model->notifyObservers();
+                               }
+                       }
+
+                       
+
+               }
+               return true;
+       }
 
        //=========================================================================
 
index 66c3e2a6c1bfbfdb7fc9f9bc4350a454c856259f..fdc8a246dce53dc5239554c61c0f523e57836abb 100644 (file)
@@ -46,6 +46,7 @@ Version:   $Revision$
 //Includes same project
 #include "GlobalConstants.h"
 #include "GObjectController.h"
+#include "GPortModel.h"
 
 //Includes creaMaracasVisu
 
@@ -67,6 +68,8 @@ namespace bbtk
                
                //Public methods
 
+               virtual bool  OnLeftButtonDown(); 
+               virtual bool  OnLeftButtonUp();
 
        private:
 
index 162694013dedf5f93bc82b54675b84ed19d1362b..5c36d4b2ab66fc3462b71f45ade703a68d4c11e2 100644 (file)
@@ -51,7 +51,7 @@ namespace bbtk
        }
 
        //=========================================================================
-       void vtkGBlackBoxView::update()
+       void vtkGBlackBoxView::update(int command)
        {
                if(_model->getState()==NOTHING_HAPPENS)
                {
@@ -74,6 +74,15 @@ namespace bbtk
                        _objectActor->GetProperty()->SetColor(BOXCONTOUR_SELECTED_R,BOXCONTOUR_SELECTED_G,BOXCONTOUR_SELECTED_B);
                }
 
+               double xInic, yInic,zInic,xFin, yFin,zFin;
+               _model->getInicPoint(xInic,yInic,zInic);
+               _model->getFinalPoint(xFin, yFin,zFin);
+
+               _pts->SetPoint(0, xInic, yInic, 0 );
+               _pts->SetPoint(1, xInic, yFin, 0 );
+               _pts->SetPoint(2, xFin, yFin, 0 );
+               _pts->SetPoint(3, xFin, yInic, 0 );
+
                _baseView->GetRenWin()->Render();
        }
 
@@ -81,7 +90,7 @@ namespace bbtk
 
        void vtkGBlackBoxView::createVtkObjects() //virtual
        {
-               vtkPoints *_pts = vtkPoints::New();     
+               _pts = vtkPoints::New();        
                vtkCellArray *lines = vtkCellArray::New();
                vtkPolyData *_pd = vtkPolyData::New();
                vtkPolyDataMapper* _bboxMapper=vtkPolyDataMapper::New();
index 34b4c5bfa10d5cff23cfc52365163dae0dd99ccb..05a536a0b23b1ffae4ad7d7a17767d722a7af5f7 100644 (file)
@@ -74,11 +74,12 @@ namespace bbtk
                vtkGBlackBoxView();
                ~vtkGBlackBoxView();
                
-               //Public methods                        
+               //Public methods                
 
        private:
 
                //Private Attributes
+               vtkPoints *_pts;
 
                //Private Methods
 
@@ -88,7 +89,7 @@ namespace bbtk
                
                //Protected Methods
                virtual void createVtkObjects();
-               virtual void update();
+               virtual void update(int command);
        };
 
 
index c20afadbdf133627b4720f415ebbead9035d549c..4e92f740266fb4bcd745c0e1b69145f9342e7b64 100644 (file)
@@ -45,6 +45,7 @@ namespace bbtk
        {
                _baseView=NULL;
                _objectActor=NULL;
+               _isFirstDragging=false;
        }
 
        //=========================================================================
@@ -53,7 +54,7 @@ namespace bbtk
        }
        //=========================================================================
 
-       void vtkGObjectView::update()//virtual
+       void vtkGObjectView::update(int command)//virtual
        {
                //virtual
        }
@@ -97,7 +98,7 @@ namespace bbtk
 
        //=========================================================================
 
-       bool vtkGObjectView::isPointInside(int X,int Y) 
+       bool vtkGObjectView::isPointInside(int X,int Y) //virtual
        {
                double xx=X,yy=Y,zz=0;
                _baseView->TransCoordScreenToWorld(xx,yy,zz);
@@ -106,6 +107,38 @@ namespace bbtk
 
        //=========================================================================
 
+       void vtkGObjectView::moveObject(int X,int Y) //virtual
+       {               
+               double xx=X,yy=Y,zz=0;
+               _baseView->TransCoordScreenToWorld(xx,yy,zz);
+
+               
+
+               if(_isFirstDragging)
+               {
+                       _isFirstDragging=false;
+                       
+                       double xInic,yInic,zInic;
+                       _model->getInicPoint(xInic,yInic,zInic);                        
+                       dragDifX=xx-xInic;
+                       dragDifY=yy-yInic;      
+               }
+
+               _model->move(xx-dragDifX,yy-dragDifY,zz);
+
+       }
+
+       //=========================================================================
+
+       void vtkGObjectView::isFirstDragging(bool param)
+       {
+               _isFirstDragging=param;
+               dragDifX=0;
+               dragDifX=0;
+       }
+
+       //=========================================================================
+
 }  // EO namespace bbtk
 
 // EOF
index 1397ef4661048cceae023e9f10c91ba9475b8869..97ea5776d8723b60b4dad933af053dee161601af 100644 (file)
@@ -79,13 +79,19 @@ namespace bbtk
                void setBaseView(wxVtkBaseView* baseView);
                void initVtkObjects();
                
-               bool isPointInside(int X,int Y);
+               virtual bool isPointInside(int X,int Y);
+               virtual void moveObject(int X, int Y);
 
-               virtual void update();
+               virtual void update(int command);
+               void isFirstDragging(bool param);
 
        private:
 
                //Private Attributes
+               bool _isFirstDragging;
+               double dragDifX;
+               double dragDifY;
+
 
                //Private Methods
                
@@ -95,7 +101,7 @@ namespace bbtk
                wxVtkBaseView *_baseView;
                GObjectModel *_model;
                vtkActor *_objectActor;
-
+               
                //Protected Methods
                virtual void createVtkObjects();
                virtual void addVtkActors();
index d224f301b70df8ece8a43d625c52032ad4846ea2..d1ab127c683b6364be009dde5ad968b181802f07 100644 (file)
@@ -51,25 +51,37 @@ namespace bbtk
        }
 
        //=========================================================================
-       void vtkGPortView::update()
+       void vtkGPortView::update(int command)
        {
-               //paint();
                if(_model->getState()==HIGHLIGHTED)
                {
-                       _objectActor->GetProperty()->SetColor(0.0,0.2,0.5);
+                       _objectActor->GetProperty()->SetColor(0.8,0.2,0.5);
                }
                else
                {
                        _objectActor->GetProperty()->SetColor(0.3,0.2,0.2);
                }
+
+               double xInic, yInic,zInic,xFin, yFin,zFin;
+
+               _model->getInicPoint(xInic,yInic,zInic);
+               _model->getFinalPoint(xFin, yFin,zFin);
+
+               _pts->SetPoint(0, xInic, yInic, 0 );
+               _pts->SetPoint(1, xInic, yFin, 0 );
+               _pts->SetPoint(2, xFin, yFin, 0 );
+               _pts->SetPoint(3, xFin, yInic, 0 );
+
                _baseView->GetRenderer()->Render();
+               _baseView->GetRenWin()->Render();
+
        }
 
        //=========================================================================
 
        void vtkGPortView::createVtkObjects() //virtual
        {
-               vtkPoints *_pts = vtkPoints::New();     
+               _pts = vtkPoints::New();        
                vtkCellArray *lines = vtkCellArray::New();
                vtkPolyData *_pd = vtkPolyData::New();
                vtkPolyDataMapper* _bboxMapper=vtkPolyDataMapper::New();
@@ -81,8 +93,6 @@ namespace bbtk
 
                _model->getInicPoint(xInic,yInic,zInic);
                _model->getFinalPoint(xFin, yFin,zFin);
-               cout<<"RaC vtkGPortView::createVtkObjects() xInic="<<xInic<< " yInic="<<yInic<<" zInic="<<zInic<<endl;
-               cout<<"RaC vtkGPortView::createVtkObjects() xFin="<<xFin<< " yFin="<<yFin<<" zFin="<<zFin<<endl;
 
                _pts->SetPoint(0, xInic, yInic, 0 );
                _pts->SetPoint(1, xInic, yFin, 0 );
index fb21d32ebcc241464d498e4e2c03efd5a00b7286..d06e066d9d5509b9818ff7465c41d78dd98a4072 100644 (file)
@@ -79,6 +79,7 @@ namespace bbtk
        private:
 
                //Private Attributes
+               vtkPoints *_pts;
 
                //Private Methods
 
@@ -88,7 +89,7 @@ namespace bbtk
                
                //Protected Methods
                virtual void createVtkObjects();
-               virtual void update();
+               virtual void update(int command);
        };