Преглед на файлове

0625 修改bug重复导入结果文件报错

caizm преди 2 години
родител
ревизия
d6b2b2b24d

+ 105 - 79
CAE_Solution/src/VTK/Manager/ResultMeshManager.cpp

@@ -87,7 +87,7 @@ ResultMeshManager::ResultMeshManager()
     solidSurfaceW_ = NULL;
     sliceW_ = NULL;
     streamW_ = NULL;
-//    xyplot2dW_ = NULL;
+    //    xyplot2dW_ = NULL;
 
     changeRangeFlag = false;
     surfaceHideFlag = true;
@@ -262,10 +262,10 @@ void ResultMeshManager::Clear()
     surfaceActorColor_.push_back(1);
     surfaceActorTransparency_ = 1;
 
-//    if (animationWidget_ != NULL)
-//    {
-//        animationWidget_->RestoreWidget();
-//    }
+    //    if (animationWidget_ != NULL)
+    //    {
+    //        animationWidget_->RestoreWidget();
+    //    }
     if (contourWidget_ != NULL)
     {
         contourWidget_->RestoreWidget();
@@ -277,23 +277,39 @@ void ResultMeshManager::Clear()
     if (vectorWidget_ != NULL)
     {
         //vectorWidget_->RestoreWidget();
+        /*vectorWidget_->dataU.clear();
+        vectorWidget_->dataV.clear();
+        vectorWidget_->dataW.clear();
+        vectorWidget_->SetScaleFactor(0.02);*/
     }
     if (solidSurfaceW_ != NULL)
     {
         //solidSurfaceW_->RestoreWidget();
+        //solidSurfaceW_->SetShowHideState(true);
+        //solidSurfaceW_->SetTransparency(1);
+    }
+    if (sliceW_ != NULL)
+    {
+        /*sliceW_->scalarNameVec.clear();
+        sliceW_->zoneIdVec.clear();
+        sliceW_->index = 0;
+        sliceW_->oldIndex = -1;*/
+        //        sliceW_->RestoreWidget();
     }
-//    if (sliceW_ != NULL)
-//    {
-//        sliceW_->RestoreWidget();
-//    }
     if (streamW_ != NULL)
     {
         //streamW_->RestoreWidget();
-    }
-//    if (xyplot2dW_ != NULL)
-//    {
-//        xyplot2dW_->RestoreWidget();
-//    }
+        /*streamW_->dataU.clear();
+        streamW_->dataV.clear();
+        streamW_->dataW.clear();
+        streamW_->current_direction = "both";
+        streamW_->showstate = true;
+        streamW_->toolstate = true;*/
+    }
+    //    if (xyplot2dW_ != NULL)
+    //    {
+    //        xyplot2dW_->RestoreWidget();
+    //    }
     if (render_ != NULL)
     {
         render_->HideAllActors();
@@ -322,7 +338,9 @@ void ResultMeshManager::Clear()
         uncontour->Delete();
         uncontour = NULL;
     }
-    qDeleteAll(uncontourVec_);
+    if(!uncontourVec_.empty()){
+       qDeleteAll(uncontourVec_);
+    }
 }
 
 /**
@@ -678,6 +696,14 @@ void ResultMeshManager::DisplayMeshByIndex(int index)
                     it2->second->ShowOffScalarBar();
                 }
             }
+
+            /*for (map<string, vtkVISUnShadeMesh*>::iterator it2= unMehsIt->second.begin();
+                 it2 != unMehsIt->second.end(); it2 ++)
+            {
+                    it2->second->SetOpacity(0);
+                    it2->second->ShowOn();
+            }*/
+
         }else if (displayType == 3)//unglyph
         {
             HideAllContourActors();
@@ -688,8 +714,8 @@ void ResultMeshManager::DisplayMeshByIndex(int index)
                 if (currShowZoneNameSet_.count(it2->first))
                 {
                     it2->second->InitGlyphDisplay(vectorScalarIndexVec.at(0),
-                            vectorScalarIndexVec.at(1),
-                            vectorScalarIndexVec.at(2));//cuode
+                                                  vectorScalarIndexVec.at(1),
+                                                  vectorScalarIndexVec.at(2));//cuode
                     it2->second->SetGlyphScaleFactor(scaleFactor_);
                     it2->second->ShowOn();
                 }else
@@ -1101,7 +1127,7 @@ void ResultMeshManager::SetVectorWidget(VectorW* w)
     {
         vector<string> tmp = GetMeshScalarNameVec();//0504 append去除容器里元素的"\0000"
         //for(auto &p:tmp){
-            //p=deleteSpaces(p);
+        //p=deleteSpaces(p);
         //}
         vectorWidget_->GetData_u(tmp);
         vectorWidget_->GetData_v(tmp);
@@ -1400,11 +1426,11 @@ void ResultMeshManager::InitWidgetsParameter()
         streamW_->SetData_v(GetMeshScalarNameVec());
         streamW_->SetData_w(GetMeshScalarNameVec());
     }
-//    if (xyplot2dW_ != NULL)
-//    {
-//        xyplot2dW_->SetArea(zoneNameVec_);
-//        xyplot2dW_->SetYAxis(GetMeshScalarNameVec());
-//    }
+    //    if (xyplot2dW_ != NULL)
+    //    {
+    //        xyplot2dW_->SetArea(zoneNameVec_);
+    //        xyplot2dW_->SetYAxis(GetMeshScalarNameVec());
+    //    }
 }
 
 /**
@@ -1687,8 +1713,8 @@ void ResultMeshManager::HideSliceActors()
   * @date 20230225
   */
 void ResultMeshManager::SetAllSliceState(vector<int> sliceId, vector<bool> solidState, vector<bool> planeWidgetState, vector<vector<double>> nomal,
-                      vector<vector<double>> posision, vector<string> type, vector<string> contourName, vector<int> level,
-                      vector<bool> planeState, vector<bool>labelState)
+                                         vector<vector<double>> posision, vector<string> type, vector<string> contourName, vector<int> level,
+                                         vector<bool> planeState, vector<bool>labelState)
 {
     for (int i = 0; i < sliceId.size(); i ++)
     {
@@ -1826,27 +1852,27 @@ void ResultMeshManager::UpdataCurrUnstructSource()
         num ++;
     }
     vector<vtkVISUnstructuredGridSource*> vec;
-        map<double, map<string, vtkVISUnContour*>>::iterator it = vtkVisZoneMeshMap_.find(time);
-        if (it != vtkVisZoneMeshMap_.end())
+    map<double, map<string, vtkVISUnContour*>>::iterator it = vtkVisZoneMeshMap_.find(time);
+    if (it != vtkVisZoneMeshMap_.end())
+    {
+        for (map<string, vtkVISUnContour*>::iterator it2= it->second.begin();
+             it2 != it->second.end(); it2 ++)
         {
-            for (map<string, vtkVISUnContour*>::iterator it2= it->second.begin();
-                 it2 != it->second.end(); it2 ++)
-            {
-                if (currShowZoneNameSet_.count(it2->first))
-                {
-                    vtkVISUnstructuredGridSource* unGrid = vtkVISUnstructuredGridSource::New();
-                    unGrid = it2->second->GetDatSource();
-                    vec.push_back(unGrid);
-                }
-            }
-            if (currAddDataSource_ != NULL)
+            if (currShowZoneNameSet_.count(it2->first))
             {
-                delete currAddDataSource_;
-                currAddDataSource_ = NULL;
+                vtkVISUnstructuredGridSource* unGrid = vtkVISUnstructuredGridSource::New();
+                unGrid = it2->second->GetDatSource();
+                vec.push_back(unGrid);
             }
-            currAddDataSource_ = new vtkVISAddUnGridDataSource();
-            currAddDataSource_->SetVISUnGridDataSource(vec);
         }
+        if (currAddDataSource_ != NULL)
+        {
+            delete currAddDataSource_;
+            currAddDataSource_ = NULL;
+        }
+        currAddDataSource_ = new vtkVISAddUnGridDataSource();
+        currAddDataSource_->SetVISUnGridDataSource(vec);
+    }
 }
 
 /**
@@ -2057,15 +2083,15 @@ void ResultMeshManager::GetActorText(string text_, vector<double> position_XY, d
     }
     titleText_ = vtkTextActor::New();
     if(!text_.empty())
-     {
-         const char *TitleText = text_.c_str();
-         titleText_->SetInput(TitleText);
-         titleText_->SetDisplayPosition(position_XY.at(0),position_XY.at(1));
-         titleText_->GetTextProperty()->SetFontSize(fontsize);
-         titleText_->GetTextProperty()->SetColor(color.at(0),color.at(1),color.at(2));
-         render_->GetRenderer()->AddActor2D(titleText_);
-         render_->Update();
-     }
+    {
+        const char *TitleText = text_.c_str();
+        titleText_->SetInput(TitleText);
+        titleText_->SetDisplayPosition(position_XY.at(0),position_XY.at(1));
+        titleText_->GetTextProperty()->SetFontSize(fontsize);
+        titleText_->GetTextProperty()->SetColor(color.at(0),color.at(1),color.at(2));
+        render_->GetRenderer()->AddActor2D(titleText_);
+        render_->Update();
+    }
 }
 
 /**
@@ -2268,34 +2294,34 @@ void ResultMeshManager::ChangeMeshType(int type)
         surfaceActorColor_.push_back(1);
         surfaceActorTransparency_ = 1;
 
-//        if (contourWidget_ != NULL)
-//        {
-//            contourWidget_->RestoreWidget();
-//        }
-//        if (lineWidget_ != NULL)
-//        {
-//            lineWidget_->RestoreWidget();
-//        }
-//        if (vectorWidget_ != NULL)
-//        {
-//            vectorWidget_->RestoreWidget();
-//        }
-//        if (solidSurfaceW_ != NULL)
-//        {
-//            solidSurfaceW_->RestoreWidget();
-//        }
-//        if (sliceW_ != NULL)
-//        {
-//            sliceW_->RestoreWidget();
-//        }
-//        if (streamW_ != NULL)
-//        {
-//            streamW_->RestoreWidget();
-//        }
-//        if (xyplot2dW_ != NULL)
-//        {
-//            xyplot2dW_->RestoreWidget();
-//        }
+        //        if (contourWidget_ != NULL)
+        //        {
+        //            contourWidget_->RestoreWidget();
+        //        }
+        //        if (lineWidget_ != NULL)
+        //        {
+        //            lineWidget_->RestoreWidget();
+        //        }
+        //        if (vectorWidget_ != NULL)
+        //        {
+        //            vectorWidget_->RestoreWidget();
+        //        }
+        //        if (solidSurfaceW_ != NULL)
+        //        {
+        //            solidSurfaceW_->RestoreWidget();
+        //        }
+        //        if (sliceW_ != NULL)
+        //        {
+        //            sliceW_->RestoreWidget();
+        //        }
+        //        if (streamW_ != NULL)
+        //        {
+        //            streamW_->RestoreWidget();
+        //        }
+        //        if (xyplot2dW_ != NULL)
+        //        {
+        //            xyplot2dW_->RestoreWidget();
+        //        }
         render_->HideAllActors();
 
         if (type == 0)

+ 1 - 0
CAE_Solution/src/VTK/Manager/resultmanager.h

@@ -195,6 +195,7 @@ public:
     vtkVISUnSlice* xyplot2dSlice_;
     vector<vtkVISAddUnGridDataSource*> currentVISGridVec_;
 
+    //vtk
     vtkVISUnstructuredGridSource* source;
     vtkVISUnShadeMesh* unmesh;
     vtkVISUnContour* uncontour;

+ 8 - 8
CAE_Solution/src/VTK/QVTKRenderer/qvtkrenderer.cpp

@@ -523,14 +523,14 @@ void QVTKRenderer::SetLineWidth(float width)
 void QVTKRenderer::HideAllActors()
 {
     vtkPropCollection* pc = renderer->GetViewProps();
-        pc->InitTraversal();
-        for(int i = 0; i < pc->GetNumberOfItems(); i ++)
-        {
-            pc->GetNextProp()->VisibilityOff();
-        }
-        //0425 append
-        renderer->ResetCamera();
-        renderWin->Render();
+    pc->InitTraversal();
+    for(int i = 0; i < pc->GetNumberOfItems(); i ++)
+    {
+        pc->GetNextProp()->VisibilityOff();
+    }
+    //0425 append
+    renderer->ResetCamera();
+    renderWin->Render();
 }
 
 /*

+ 1 - 1
CAE_Solution/src/VTK/widget/Sslicewidget.h

@@ -41,7 +41,7 @@ public:
     int getIndex();
     void setIndex(int);
     QMap<int,SliceDisplayWidget*> map_SliceDisplayWidget;
-private:
+public:
 
     SliceDisplayWidget *Setting;
     int index;

+ 1 - 0
CAE_Solution/src/main.cpp

@@ -33,6 +33,7 @@ int main(int argc, char *argv[])
         QGuiApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
     }
 #endif
+    //QApplication::setAttribute(Qt::AA_ShareOpenGLContexts);//opengl共享上下文
     QSurfaceFormat::setDefaultFormat(QVTKOpenGLNativeWidget::defaultFormat());//必需
     qRegisterMetaType<std::string>("std::string");
     QApplication a(argc, argv);

+ 24 - 0
CAE_Solution/src/threadPool_and_statemachine/dealWith/handlepool.cpp

@@ -491,6 +491,7 @@ bool handlePool::resultImport(boostJsonObject *object_, QVTKRenderer *renderer_)
         delete qmapResultmanager.value(object_->proId);
     }
     qmapResultmanager[object_->proId]=(set_map_resultManager(object_,rsManager));
+    clear_map_pid(object_->proId);//重复导入后清空云图等容器,重新存储
 
     contour_sendrange_flag = true;//标志位,第一次加载result,即为真,云图发送range
     line_sendrange_flag = true;//标志位,第一次加载result,即为真,等值线发送range
@@ -1143,6 +1144,29 @@ void handlePool::animationSliderChanged(QString str)
     }
 }
 
+/*
+ * @brief: clear map when resultimported anew
+ * @param: void
+ * @ret: void
+ * @birth: created by czm in 20230625
+ */
+void handlePool::clear_map_pid(string pid)
+{
+    QMap<string,ContourDisplay*>::iterator iter1 = map_contourdisplay.find(pid);
+    map_contourdisplay.erase(iter1);
+    QMap<string,LineDisplay*>::iterator iter2 = map_linedisplay.find(pid);
+    map_linedisplay.erase(iter2);
+    QMap<string,Vectordisplay*>::iterator iter3 = map_vectordisplay.find(pid);
+    map_vectordisplay.erase(iter3);
+    QMap<string,SolidSurface*>::iterator iter4 = map_solidsdisplay.find(pid);
+    map_solidsdisplay.erase(iter4);
+    QMap<string,SliceWidget*>::iterator iter5 = map_slicedisplay.find(pid);
+    map_slicedisplay.erase(iter5);
+    QMap<string,StreamWidget*>::iterator iter6 = map_streamdisplay.find(pid);
+    map_streamdisplay.erase(iter6);
+
+}
+
 /*
  * @brief: get map which save meshmanager
  * @param: void

+ 1 - 0
CAE_Solution/src/threadPool_and_statemachine/dealWith/handlepool.h

@@ -73,6 +73,7 @@ public:
     pid_meshManager* set_map_meshManager(boostJsonObject*,MeshManager*);
     pid_resultManager* set_map_resultManager(boostJsonObject*,ResultManager*);
     void animationSliderChanged(QString);
+    void clear_map_pid(string);
 
 
 private: