]> Creatis software - bbtkGEditor.git/blobdiff - lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx
#3066 bbGEditor Bug New Normal - Refresh vtk objects
[bbtkGEditor.git] / lib / EditorGraphicBBS / bbsWxGUIEditorGraphic / wxVtkSceneManager.cxx
index f29a4e8f3cd33b1a4ec76cd6f8058ca05634b88d..af87221b5d01c3da0f519edf9f6df0b8631b6bff 100644 (file)
@@ -280,6 +280,7 @@ int wxVtkSceneManager::createGBlackBox(int x, int y, std::string packageName,std
 
 //EED 15 oct 2012      BlackBoxDescriptor::Pointer descriptor = GObjectsMVCFactory::getInstance()->getBlackBoxDescriptor(packageName, boxType);
        
+
        Package::Pointer k;
        std::map< std::string, BlackBoxDescriptor::Pointer> mapDesc;
        try{
@@ -332,7 +333,6 @@ int wxVtkSceneManager::createGBlackBox(int x, int y, std::string packageName,std
        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;
@@ -344,7 +344,6 @@ int wxVtkSceneManager::createGBlackBox(int x, int y, std::string packageName,std
        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) {
@@ -357,6 +356,7 @@ int wxVtkSceneManager::createGBlackBox(int x, int y, std::string packageName,std
        //(NOTE: Refresh is only made by the view)
        view->setModel(model);
        view->setBaseView(_baseView);
+
        view->initVtkObjects();
 
        //Associates the controller with the correspondent model and view
@@ -526,7 +526,11 @@ GPortController* wxVtkSceneManager::createGPort(int portType,std::string bbtkNam
        //(NOTE: Refresh is only made by the view)
        view->setModel(model);
        view->setBaseView(_baseView);
-       view->initVtkObjects();
+
+//EED017       view->initVtkObjects();
+       view->createVtkObjects();
+//  view->addVtkActors();
+
 
        //Associates the controller with the correspondent model and view
        controller->setModelAndView(model, view);
@@ -536,6 +540,7 @@ GPortController* wxVtkSceneManager::createGPort(int portType,std::string bbtkNam
        addObjectController(controller);
 
        return (GPortController*) controller;
+
 }
 
 //=========================================================================
@@ -570,7 +575,8 @@ int wxVtkSceneManager::createGConnector(GPortModel* startPort)
          * JGRR AND CM
          * Width increased from 2 to 3, it simplifies line handling and spline control :P
          * @param WidthLine  
-         */ 
+         */
+ //EED2017
         manContourView->SetWidthLine( 3 ) ;
        manContourView->SetShowText(false);
 
@@ -1437,9 +1443,10 @@ std::string wxVtkSceneManager::getDiagramBBS(bool wln) {
                        script += LineNumber(wln, lnNmbr);
                        script += "new ";
                        int id = boxes[i];
-                       GObjectController *control = _controllers[id];
-                       GBlackBoxModel *model = (GBlackBoxModel*) control->getModel();
+                       GObjectController *control      = _controllers[id];
+                       GBlackBoxModel *model           = (GBlackBoxModel*) control->getModel();
 
+                       script += model->getBBTKPackage()+":";
                        script += model->getBBTKType();
                        script += " ";
                        script += model->getBBTKName();
@@ -1503,6 +1510,7 @@ std::string wxVtkSceneManager::getDiagramBBS(bool wln) {
                        }
                        else
                        {
+                                       script += LineNumber(wln, lnNmbr);
                                        script += "connect ";
                                        script += startBox->getBBTKName();
                                        script += ".";
@@ -1518,13 +1526,17 @@ std::string wxVtkSceneManager::getDiagramBBS(bool wln) {
                                        script += "\n";
                        }
 
+                       script += LineNumber(wln, lnNmbr);
                        script += "\n";
                }
 
                script += LineNumber(wln, lnNmbr);
                script += "\n";
 
+               script += LineNumber(wln, lnNmbr);
                script += "\n";
+
+               script += LineNumber(wln, lnNmbr);
                script += "# Complex input ports\n";
                script += complexInputs;
 
@@ -1630,6 +1642,7 @@ std::string wxVtkSceneManager::saveComplexBoxBBS() {
                GObjectController *control = _controllers[id];
                GBlackBoxModel *model = (GBlackBoxModel*) control->getModel();
 
+               script += model->getBBTKPackage()+":";
                script += model->getBBTKType();
                script += " ";
                script += model->getBBTKName();
@@ -1767,23 +1780,45 @@ void wxVtkSceneManager::refresh() {
 }
 //=========================================================================
 
-void wxVtkSceneManager::refreshScene() {
+void wxVtkSceneManager::refreshScene() 
+{
        _baseView->RefreshView();
 }
 
 //=========================================================================
 
-void wxVtkSceneManager::centerView() {
+void wxVtkSceneManager::centerView() 
+{
+       double bb[6];
+       _baseView->GetRenderer()->ComputeVisiblePropBounds(bb);
+
        double temp[3];
        _baseView->GetRenderer()->GetActiveCamera()->GetFocalPoint(temp);
        _baseView->GetRenderer()->GetActiveCamera()->SetFocalPoint(0, 0, temp[2]);
        _baseView->GetRenderer()->GetActiveCamera()->GetPosition(temp);
        _baseView->GetRenderer()->GetActiveCamera()->SetPosition(0, 0, temp[2]);
+
+       _baseView->GetRenderer()->ResetCamera();
+       _baseView->GetRenderer()->ResetCameraClippingRange();
+
+/*
+       double tt=_baseView->GetRenderer()->GetNearClippingPlaneTolerance();
+       printf("EED wxVtkSceneManager::centerView() tolerance=%f\n",tt);
+       double cr1,cr2;
+       _baseView->GetRenderer()->GetActiveCamera()->GetClippingRange(cr1,cr2);
+       printf("EED wxVtkSceneManager::centerView() cr1=%f  cr2=%f\n",cr1,cr2);
+       _baseView->GetRenderer()->GetActiveCamera()->SetClippingRange(0.01,100000);
+       _baseView->GetRenderer()->GetActiveCamera()->GetClippingRange(cr1,cr2);
+       printf("EED wxVtkSceneManager::centerView() cr1=%f  cr2=%f\n",cr1,cr2);
+*/
+
+       _baseView->GetRenderer()->Render();
 }
 
 //=========================================================================
 
-void wxVtkSceneManager::saveDiagram(std::string &content) {
+void wxVtkSceneManager::saveDiagram(std::string &content) 
+{
        char buffer[50];
 
        content += "CATEGORY:";
@@ -1871,14 +1906,14 @@ void wxVtkSceneManager::saveDiagram(std::string &content) {
        
        for (int i = 0; i < bsize; i++) {
                int id = boxes[i];
-               std::cout<<"id "<<id<<std::endl;//CFT
+//             std::cout<<"id "<<id<<std::endl;//CFT
                GObjectController *cont = _controllers[id];
-               std::cout<<"nombre: "<<cont->getStatusText()<<std::endl;//CFT
-               std::cout<<"tipo: "<<cont->getModel()->getBBTKType()<<std::endl;//CFT
-               //boxesDiagram[i] = cont->getModel()->getBBTKType();//CFT
-               std::cout<<"nname: "<<cont->getModel()->getBBTKName()<<std::endl;//CFT
-               std::cout<<"categorie: "<<GetCategory()<<std::endl;//CFT
-               std::cout<<"type: "<<cont->getModel()->getGObjectType()<<std::endl;//CFT
+//             std::cout<<"nombre: "<<cont->getStatusText()<<std::endl;//CFT
+//             std::cout<<"tipo: "<<cont->getModel()->getBBTKType()<<std::endl;//CFT
+//             //boxesDiagram[i] = cont->getModel()->getBBTKType();//CFT
+//             std::cout<<"nname: "<<cont->getModel()->getBBTKName()<<std::endl;//CFT
+//             std::cout<<"categorie: "<<GetCategory()<<std::endl;//CFT
+//             std::cout<<"type: "<<cont->getModel()->getGObjectType()<<std::endl;//CFT
                cont->getModel()->save(content);
        }
 
@@ -1915,7 +1950,6 @@ void wxVtkSceneManager::getCleanLine(stringstream &inputStream, std::string &lin
 //=========================================================================
 void wxVtkSceneManager::loadDiagram(stringstream &inputStream) 
 {
-
        int size;
        std::string version = "<void>";
        std::string line = "";
@@ -2175,7 +2209,8 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream)
                std::istringstream is(result);
                is >> numBoxes;
 
-               for (int i = 0; i < numBoxes; i++) {
+               for (int i = 0; i < numBoxes; i++) 
+               {
                        //----------
                        getCleanLine(inputStream, line);//BOX
                        getCleanLine(inputStream, line);//package:type:name
@@ -2247,7 +2282,8 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream)
                        
                        
                        bool boxExecutable = false;
-                       if (isExec == "TRUE") {
+                       if (isExec == "TRUE") 
+                       {
                                boxExecutable = true;
                        }
 
@@ -2304,7 +2340,8 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream)
                isCons >> numConns;
                
                
-               for (int i = 0; i < numConns; i++) {
+               for (int i = 0; i < numConns; i++) 
+               {
                        //----------
                        getCleanLine(inputStream, line);//CONNECTION
                        getCleanLine(inputStream, line);//Startbox.PortName:EndBox.PortName
@@ -2320,7 +2357,6 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream)
                        result = strtok(NULL, delims);
                        std::string nameEndPort(result);
 
-
                        int idCon = configGConnetion(nameStartBox, nameStartPort,nameEndBox, nameEndPort);
 
                        if (version != "1.0") {