]> Creatis software - bbtkGEditor.git/commitdiff
*** empty log message ***
authordavila <>
Thu, 9 Sep 2010 08:07:45 +0000 (08:07 +0000)
committerdavila <>
Thu, 9 Sep 2010 08:07:45 +0000 (08:07 +0000)
lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGBlackBoxView.cxx
lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGBoxView.cxx
lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGObjectView.cxx
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.h

index a617d701a43a2e51e5de69483af25d1c74680151..5377d7be778b08ed1fcaafa723dde49fc42caf1b 100644 (file)
@@ -84,11 +84,11 @@ namespace bbtk
        {
 
                //------------
-               _pts = vtkPoints::New();        
+               _pts                            = vtkPoints::New();     
                vtkCellArray *lines = vtkCellArray::New();
-               vtkPolyData *_pd = vtkPolyData::New();
-               _borderPolyMapper=vtkPolyDataMapper::New();
-               _borderObjectActor=vtkActor::New();
+               vtkPolyData *_pd        = vtkPolyData::New();
+               _borderPolyMapper       = vtkPolyDataMapper::New();
+               _borderObjectActor      = vtkActor::New();
                                
                _pts->SetNumberOfPoints(4);
 
@@ -122,8 +122,8 @@ namespace bbtk
 
                vtkCellArray *strip = vtkCellArray::New();
                vtkPolyData *pdFill = vtkPolyData::New();
-               _fillPolyMapper=vtkPolyDataMapper::New();
-               _fillObjectActor=vtkActor::New();
+               _fillPolyMapper         = vtkPolyDataMapper::New();
+               _fillObjectActor        = vtkActor::New();
 
                // RaC In the actual version, zInic=zFin=900
 
@@ -145,13 +145,9 @@ namespace bbtk
 
                //------------
 
-               _boxTextActor = vtkTextActor3D::New();
-               std::string temp = _model->getBBTKType();
-               temp+=":";
-               temp+=_model->getBBTKName();
+               _boxTextActor           = vtkTextActor3D::New();
                _boxTextActor->GetTextProperty()->SetFontSize(80);
                _boxTextActor->GetTextProperty()->BoldOn();
-               _boxTextActor->SetInput(temp.c_str());
 
                //------------
 
@@ -180,6 +176,10 @@ namespace bbtk
 
        void vtkGBlackBoxView::updatePositionTextActor(double xInic, double yInic, double zInic)
        {
+               std::string temp        = _model->getBBTKType();
+               temp+=":";
+               temp+=_model->getBBTKName();
+               _boxTextActor->SetInput(temp.c_str());
                _boxTextActor->SetPosition(xInic+4,yInic-7,zInic);
                _boxTextActor->SetScale(0.05,0.05,1);
        }
index f6121e4be895ef2b116c0b6b7e5d9616476447ef..89d0252ddb2fb9214c3b8734f0851878e9bccd18 100644 (file)
@@ -82,11 +82,11 @@ namespace bbtk
        {
 
                //------------
-               _pts = vtkPoints::New();        
+               _pts                            = vtkPoints::New();     
                vtkCellArray *lines = vtkCellArray::New();
-               vtkPolyData *_pd = vtkPolyData::New();
-               _borderPolyMapper=vtkPolyDataMapper::New();
-               _borderObjectActor=vtkActor::New();
+               vtkPolyData *_pd        = vtkPolyData::New();
+               _borderPolyMapper       = vtkPolyDataMapper::New();
+               _borderObjectActor      = vtkActor::New();
                                
                _pts->SetNumberOfPoints(4);
 
@@ -118,10 +118,10 @@ namespace bbtk
                
                ///************************* FILL *************************
 
-               vtkCellArray *strip = vtkCellArray::New();
-               vtkPolyData *pdFill = vtkPolyData::New();
-               _fillPolyMapper=vtkPolyDataMapper::New();
-               _fillObjectActor=vtkActor::New();
+               vtkCellArray *strip             = vtkCellArray::New();
+               vtkPolyData *pdFill             = vtkPolyData::New();
+               _fillPolyMapper                 = vtkPolyDataMapper::New();
+               _fillObjectActor                = vtkActor::New();
 
                // RaC In the actual version, zInic=zFin=900
 
index 79026ba73c1b7d1aea6d60a8da0d51441460a497..2466e2c62253a65f2e499cab03759ad4b806e405 100644 (file)
@@ -43,12 +43,12 @@ namespace bbtk
        //=========================================================================
        vtkGObjectView::vtkGObjectView()
        {
-               _baseView=NULL;
-               _borderObjectActor=NULL;
-               _fillObjectActor=NULL;
-               _isStartDragging=false;
+               _baseView                       = NULL;
+               _borderObjectActor      = NULL;
+               _fillObjectActor        = NULL;
+               _isStartDragging        = false;
                
-               _state = NOTHING_HAPPENS;
+               _state                          = NOTHING_HAPPENS;
        }
 
        //=========================================================================
@@ -66,14 +66,14 @@ namespace bbtk
        
        void vtkGObjectView::setModel(GObjectModel *model)
        {
-               _model=model;
+               _model = model;
        }
 
        //=========================================================================
        
        void vtkGObjectView::setBaseView(wxVtkBaseView* baseView)
        {
-               _baseView=baseView;
+               _baseView = baseView;
        }
 
        //=========================================================================
index 4a30692602d990b6e8dd43403d6fada88180fb60..1573fd28474a9519760dca9b5423427995cbdede 100644 (file)
@@ -105,23 +105,52 @@ namespace bbtk
                _baseView->Refresh();
        }
 
+       //=========================================================================
+  
+       std::string wxVtkSceneManager::generateANewNameForABox()
+       {
+               _numBoxes++;
+               std::stringstream boxname;
+               if(_numBoxes<10)
+               {
+                       boxname << "Box0" << _numBoxes;
+               }else{
+                       boxname << "Box" << _numBoxes;
+               }
+               return boxname.str();
+       }
+
+       //=========================================================================
+  
+       std::string wxVtkSceneManager::findANewNameForABox()
+       {
+               std::string boxname=generateANewNameForABox();
+
+               while (boxExist(boxname)==true)
+               {
+                       boxname=generateANewNameForABox();
+               } // while
+
+               return boxname;
+       }
+
        //=========================================================================
 
        int wxVtkSceneManager::createGBlackBox(int x, int y, std::string packageName, std::string boxType)
        {
-               _worldState = NOTHING_HAPPENS;
-               int windowWidth=_baseView->GetRenWin()->GetSize()[0];
-               int windowHeight=_baseView->GetRenWin()->GetSize()[1];
+               _worldState                                                             = NOTHING_HAPPENS;
+               int windowWidth                                                 = _baseView->GetRenWin()->GetSize()[0];
+               int windowHeight                                                = _baseView->GetRenWin()->GetSize()[1];
 
-               int type = GBLACKBOX;
+               int type                                                                = GBLACKBOX;
 
                //Create the MVC Objects
                
-               GBlackBoxModel *model = (GBlackBoxModel*)GObjectsMVCFactory::getInstance()->createGObjectModel(type);
-               vtkGObjectView *view = GObjectsMVCFactory::getInstance()->createGObjectView(type);
-               GObjectController* controller = GObjectsMVCFactory::getInstance()->createGObjectController(type);
+               GBlackBoxModel *model                                   = (GBlackBoxModel*)GObjectsMVCFactory::getInstance()->createGObjectModel(type);
+               vtkGObjectView *view                                    = GObjectsMVCFactory::getInstance()->createGObjectView(type);
+               GObjectController* controller                   = GObjectsMVCFactory::getInstance()->createGObjectController(type);
                
-               BlackBoxDescriptor::Pointer descriptor = GObjectsMVCFactory::getInstance()->getBlackBoxDescriptor(packageName, boxType);
+               BlackBoxDescriptor::Pointer descriptor  = GObjectsMVCFactory::getInstance()->getBlackBoxDescriptor(packageName, boxType);
                
                //Prepares the initial model
                //The coordinates obtained are the following. Top-Left:x=0,y=0 Bottom-Right:x=width,y=height  
@@ -135,9 +164,12 @@ namespace bbtk
                _baseView->TransCoordScreenToWorld(xx,yy,zz);
                model->setInicPoint(xx,yy,zz);
                
-               _numBoxes++;
+//EED Borrame          _numBoxes++;
                std::stringstream stream;
                
+               str:string newBoxName = findANewNameForABox();
+               stream << newBoxName;
+/* EED Borrame
                if(_numBoxes<10)
                {
                        stream << "Box0" << _numBoxes;
@@ -146,6 +178,7 @@ namespace bbtk
                {
                        stream << "Box" << _numBoxes;
                }
+*/
                std::string arraystring = stream.str();
 
                model->setBBTKName(arraystring);
@@ -1595,6 +1628,7 @@ namespace bbtk
                                bbmod->setBBTKName(name);
                                bbmod->setInicPoint(xIn,yIn,zIn);
                                bbmod->setFinalPoint(xEn,yEn,zEn);
+
                                if(isExec=="TRUE")
                                {
                                        bbmod->setExecutable(true);
@@ -1721,6 +1755,23 @@ namespace bbtk
 
        //=========================================================================
 
+       bool wxVtkSceneManager::boxExist(std::string boxname)
+       {
+               bool ok=false;
+               std::map<int, GObjectController*>::iterator it;
+               for(it = _controllers.begin(); it != _controllers.end(); ++it)
+               {
+                       GObjectController *cont = it->second;           
+                       if(cont->getModel()->getBBTKName()==boxname)
+                       {
+                               ok=true;
+                       }
+               }
+               return ok;
+       }
+
+       //=========================================================================
+
        std::vector<int> wxVtkSceneManager::getBlackBoxes()
        {
                std::vector<int> vect;
index 14f53f02a716ba91caff3689afb66d938663d5a5..acfd7e183b233619884a390b1ea956ed90f42ae9 100644 (file)
@@ -173,8 +173,11 @@ namespace bbtk
                //Center the view of the camera in the initial position
                void centerView();
 
+               bool boxExist(std::string boxname);
+               std::string generateANewNameForABox();
+               std::string findANewNameForABox();
                //-------
-               
+
 
        private: