]> Creatis software - bbtkGEditor.git/blobdiff - lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx
#3075 bbGEditor Bug New Normal - comboBox for message configuration
[bbtkGEditor.git] / lib / EditorGraphicBBS / bbsWxGUIEditorGraphic / wxVtkSceneManager.cxx
index d334129e967a9914b7ba8011441538ad2a30d7bf..002e5895014dc0ed85cfa6f5b4c7862632469d4d 100644 (file)
@@ -73,25 +73,25 @@ namespace bbtk {
        
 wxVtkSceneManager::wxVtkSceneManager(wxGEditorTabPanel *parent, wxVtk3DBaseView *baseView, int idManager,Factory::Pointer bbtkfactory) 
 {
-       _cbName                 = "ComplexBoxName";
-       _cbPackageName          = "PackageName";
-       _Author                 = "Author ??";
-       _Category               = "<VOID>";
-       _Description            = "Description ??";
-       _MessageKind = " ";
-       _MessageLevel = " ";
-
-       _bugTextActor_text      = "void";
+       _cbName                                 = "ComplexBoxName";
+       _cbPackageName                  = "PackageName";
+       _Author                                 = "Author ??";
+       _Category                               = "<VOID>";
+       _Description                    = "Description ??";
+       _MessageKind                    = "-";
+       _MessageLevel                   = "-";
+
+       _bugTextActor_text              = "void";
        _bugTextActor_status    = 0;
 
-       _parent                 = parent;
-       _numBoxes               = 0;
-       _idManager              = idManager;
-       _baseView               = baseView;
-       _bbtkfactory            = bbtkfactory;
+       _parent                                 = parent;
+       _numBoxes                               = 0;
+       _idManager                              = idManager;
+       _baseView                               = baseView;
+       _bbtkfactory                    = bbtkfactory;
        
-       _startDragging          = false;
-       _isComplexBox           = false;
+       _startDragging                  = false;
+       _isComplexBox                   = false;
 
        if (_baseView != NULL) {
                //EED02JUIN2010
@@ -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);
 
@@ -1504,6 +1510,7 @@ std::string wxVtkSceneManager::getDiagramBBS(bool wln) {
                        }
                        else
                        {
+                                       script += LineNumber(wln, lnNmbr);
                                        script += "connect ";
                                        script += startBox->getBBTKName();
                                        script += ".";
@@ -1519,17 +1526,21 @@ 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;
 
-               if((_MessageKind!=" ")&&(_MessageLevel!=" ")){
+               if((_MessageKind!="-")&&(_MessageLevel!="-")){
                        script += LineNumber(wln, lnNmbr);
                        script += "message ";
                        script += _MessageKind;
@@ -1631,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();
@@ -1724,13 +1736,17 @@ std::string wxVtkSceneManager::saveComplexBoxBBS() {
 
        script += "\n";
 
-       script += "message ";
-       script += _MessageKind;
-       script += " ";
-       script += _MessageLevel;
-       script += "\n";
+       if((_MessageKind!="-")&&(_MessageLevel!="-"))
+       {
+               script += "message ";
+               script += _MessageKind;
+               script += " ";
+               script += _MessageLevel;
+               script += "\n";
+       }
 
-       for (i = 0; i < (int) execBoxes.size(); i++) {
+       for (i = 0; i < (int) execBoxes.size(); i++) 
+       {
                script += "exec ";
                int id = execBoxes[i];
                GObjectController *control = _controllers[id];
@@ -1768,23 +1784,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:";
@@ -1872,14 +1910,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);
        }
 
@@ -1916,7 +1954,6 @@ void wxVtkSceneManager::getCleanLine(stringstream &inputStream, std::string &lin
 //=========================================================================
 void wxVtkSceneManager::loadDiagram(stringstream &inputStream) 
 {
-
        int size;
        std::string version = "<void>";
        std::string line = "";
@@ -2176,7 +2213,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
@@ -2248,7 +2286,8 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream)
                        
                        
                        bool boxExecutable = false;
-                       if (isExec == "TRUE") {
+                       if (isExec == "TRUE") 
+                       {
                                boxExecutable = true;
                        }
 
@@ -2305,7 +2344,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
@@ -2321,7 +2361,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") {