]> Creatis software - bbtkGEditor.git/blobdiff - lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx
Reduce Refresh Calls to Boost Speed
[bbtkGEditor.git] / lib / EditorGraphicBBS / bbsWxGUIEditorGraphic / wxVtkSceneManager.cxx
index 3d66871a0e14ee00c0ba4334eecff1ad61cb2a86..670ed13ad7c0aeff4afb3ec1939c443dc3d6e0ce 100644 (file)
@@ -61,9 +61,9 @@ wxVtkSceneManager::wxVtkSceneManager(wxGEditorTabPanel *parent,
                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
+//#endif
 
                configureBaseView();
                _worldState = NOTHING_HAPPENS;
@@ -87,9 +87,10 @@ void wxVtkSceneManager::disconnectDrop() {
 
 wxVtkSceneManager::~wxVtkSceneManager() {
        //FCY memory leaks
-       printf("EED %p ~wxVtkSceneManager()\n", this);
+       printf("EED %p ~wxVtkSceneManager() START\n", this);
        disconnectDrop();
        delete _baseView;
+       printf("EED %p ~wxVtkSceneManager() END\n", this);
 }
 
 //=========================================================================
@@ -113,7 +114,6 @@ void wxVtkSceneManager::configureBaseView() {
 
        _baseView->GetRenderer()->SetBackground(0.9, 0.9, 0.9);
        _baseView->GetRenderer()->GradientBackgroundOn();
-       _baseView->Refresh();
 
        // Actos Port_Text
        _textActor = vtkTextActor3D::New();
@@ -536,14 +536,13 @@ int wxVtkSceneManager::createGConnector(GPortModel* startPort) {
          * Width increased from 2 to 5, it simplifies line handling and spline control :P
          * @param WidthLine  
          */ 
-        manContourView->SetWidthLine( 5 ) ;
+        manContourView->SetWidthLine( 3 ) ;
        manContourView->SetShowText(false);
 
        manContourControl->SetModelView(manContourModel, manContourView);
 
        manContourControl->CreateNewManualContour();
 
-       manContourView->RefreshContour();
 
        double x, y, z;
        connectorModel->getInicPoint(x, y, z);
@@ -559,8 +558,7 @@ int wxVtkSceneManager::createGConnector(GPortModel* startPort) {
 
        int bak = manContourControl->GetNumberOfPointsManualContour() - 1;
        manContourControl->_bakIdPoint = bak;
-       manContourView->Refresh();
-
+       
        manContourControl->SetMoving(false);
 
        connectorcontroller->setModelAndView(connectorModel, connectorView);
@@ -576,6 +574,7 @@ int wxVtkSceneManager::createGConnector(GPortModel* startPort) {
        connectorModel->addObserver(connectorView);
        connectorModel->addObserver(this);
 
+        manContourView->Refresh();
        return newId;
 }
 
@@ -757,8 +756,7 @@ void wxVtkSceneManager::update(int idController, int command) {
                        manualConnectorContourView
                                        * connView =
                                                        (manualConnectorContourView*) manCont->GetManualViewBaseContour();
-                       connView->Refresh();
-
+                                     
                        std::map<int, GObjectController*>::iterator it2;
 
                        for (it2 = _controllers.begin(); it2 != _controllers.end(); ++it2) {
@@ -769,10 +767,11 @@ void wxVtkSceneManager::update(int idController, int command) {
                                }
                                cont->SetActive(true);
                        }
+                        connView->Refresh();          
                }
 
        }
-
+        
 }
 
 //=========================================================================
@@ -820,7 +819,9 @@ bool wxVtkSceneManager::OnMouseMove() {
                        int state = desc->getView()->getState();
                        desc->getModel()->getCenter(px, py, pz);
 
-                       if (state == HIGHLIGHTED) {
+                        // JGRR & CM
+                       if ((state == HIGHLIGHTED) || (state == SELECTED_POSSIBLE_CONNECTION )) {
+                        // EO JGRR & CM    
                                okStatusMessage = true;
                                updateStatusBar(desc->getStatusText());
                                if (type == GBLACKBOX) {
@@ -1023,6 +1024,7 @@ void wxVtkSceneManager::UnSelectBlackBoxes() {
                int id = _selectedObjects[i];
                GObjectController* control = _controllers[id];
                control->getView()->setState(NOTHING_HAPPENS);
+               control->getModel()->notifyObservers(_idManager);
        }// for _selectedObjects
        _selectedObjects.clear();
 }
@@ -1099,7 +1101,7 @@ bool wxVtkSceneManager::OnChar() {
                        _selectedObjects.clear();
                }
        }
-        
+        ctrlkey+=keyCode;
         /// Duplicate 
              if(ctrlkey==5){                
                 if(_selectedObjects.size()){
@@ -1210,7 +1212,7 @@ void wxVtkSceneManager::deleteObject(int id) {
                        _controllers.erase(it);
                }//if
        }// for
-       _parent->saveTempDiagram();
+       _parent->saveTempandUpdate();
 }
 
 //=========================================================================
@@ -1627,7 +1629,6 @@ void wxVtkSceneManager::deleteAllBoxes() {
        }
        _selectedObjects.clear();
        _controllers.clear();
-       refreshScene();
 }
 
 //=========================================================================
@@ -1650,8 +1651,6 @@ void wxVtkSceneManager::centerView() {
        _baseView->GetRenderer()->GetActiveCamera()->SetFocalPoint(0, 0, temp[2]);
        _baseView->GetRenderer()->GetActiveCamera()->GetPosition(temp);
        _baseView->GetRenderer()->GetActiveCamera()->SetPosition(0, 0, temp[2]);
-       _baseView->RefreshView();
-
 }
 
 //=========================================================================
@@ -2098,7 +2097,6 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream) {
 
        } // start
 
-       refresh();
 }
 //=========================================================================
 
@@ -2284,9 +2282,7 @@ int wxVtkSceneManager::addObjectController(GObjectController* objController) {
        int newId = _contLastId;//_controllers.size();
        objController->setId(newId);
        _controllers[newId] = objController;
-       std::cout
-                       << "DFCH: int wxVtkSceneManager::addObjectController(GObjectController* objController) ---- _contLastId = "
-                       << _contLastId << std::endl;
+       //std::cout << "DFCH: int wxVtkSceneManager::addObjectController(GObjectController* objController) ---- _contLastId = " << _contLastId << std::endl;
        _contLastId++;
        return newId;
 }
@@ -2385,7 +2381,6 @@ void wxVtkSceneManager::DuplicateObjects(std::map<int, GObjectController*> objec
             cont->getModel()->notifyObservers(_idManager);
 
         }
-        refreshScene();
     }