|
@@ -54,21 +54,46 @@ boostJsonObject::~boostJsonObject()
|
|
|
*/
|
|
|
void boostJsonObject::FromJson(string msg)
|
|
|
{
|
|
|
- stringstream msgs;
|
|
|
- msgs<<msg;
|
|
|
+ //qDebug()<<QString::fromStdString(msg);
|
|
|
+ stringstream msgs(msg);
|
|
|
ptree root;
|
|
|
read_json(msgs,root);//boost 方法
|
|
|
- try{
|
|
|
- this->usrId = root.get<string>("usrId");
|
|
|
- this->solverConfigid = root.get<string>("solverConfigid");
|
|
|
- this->proId = root.get<string>("proId");
|
|
|
- this->paramJson = root.get<string>("paramJson");
|
|
|
- this->action = root.get<string>("action");
|
|
|
- }catch(exception ex){
|
|
|
- cout<<ex.what()<<endl;
|
|
|
- return;
|
|
|
+
|
|
|
+ this->usrId = root.get<string>("usrId");
|
|
|
+ this->solverConfigid = root.get<string>("solverConfigid");
|
|
|
+ this->proId = root.get<string>("proId");
|
|
|
+ this->paramJson = root.get<string>("paramJson");
|
|
|
+ this->action = root.get<string>("action");
|
|
|
+
|
|
|
+ if(this->action == "SliceDisplayApply"){
|
|
|
+ ptree items_arr;
|
|
|
+ ptree items = root.get_child("paramJson");
|
|
|
+ for(ptree::iterator it = items.begin();it!= items.end();++it){
|
|
|
+ items_arr = it->second;
|
|
|
+ ptree::iterator it1 = items_arr.begin();
|
|
|
+ for(it1;it1!=items_arr.end();it1++){
|
|
|
+ sliceDisplay_struct *sd_struct_ = new sliceDisplay_struct();
|
|
|
+ sd_struct_->index = it1->second.get<int>("index");
|
|
|
+ sd_struct_->index = sd_struct_->index -1;
|
|
|
+ sd_struct_->solid_state = it1->second.get<bool>("solid_state");
|
|
|
+ sd_struct_->sectional_plane_state = it1->second.get<bool>("sectional_plane_state");
|
|
|
+ sd_struct_->normal_x = it1->second.get<double>("normal_x");
|
|
|
+ sd_struct_->normal_y = it1->second.get<double>("normal_y");
|
|
|
+ sd_struct_->normal_z = it1->second.get<double>("normal_z");
|
|
|
+ sd_struct_->position_x = it1->second.get<double>("position_x");
|
|
|
+ sd_struct_->position_y = it1->second.get<double>("position_y");
|
|
|
+ sd_struct_->position_z = it1->second.get<double>("position_z");
|
|
|
+ sd_struct_->type = it1->second.get<string>("type");
|
|
|
+ sd_struct_->variableName = it1->second.get<string>("variableName");
|
|
|
+ sd_struct_->level = it1->second.get<int>("level");
|
|
|
+ sd_struct_->sectional_contour_state = it1->second.get<bool>("sectional_contour_state");
|
|
|
+ sd_struct_->scalar_value_state = it1->second.get<bool>("scalar_value_state");
|
|
|
+ vec_sd_struct.push_back(sd_struct_);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ FromParamJson(this->paramJson);
|
|
|
}
|
|
|
- FromParamJson(this->paramJson);
|
|
|
}
|
|
|
|
|
|
/*
|
|
@@ -144,19 +169,36 @@ string boostJsonObject::ToJson(string type, QMap<QString, string> map_)
|
|
|
item.put("showHideState",map_["showHideState"]);
|
|
|
}else if(type == "addPage_slice"){
|
|
|
item.put("msgType","addPage_slice_param");
|
|
|
+ item.put("index",map_["index"]);
|
|
|
item.put("position_x",map_["position_x"]);
|
|
|
item.put("position_y",map_["position_y"]);
|
|
|
item.put("position_z",map_["position_z"]);
|
|
|
- item.put("min_position_x",map_["min_position_x"]);
|
|
|
- item.put("max_position_x",map_["max_position_x"]);
|
|
|
- item.put("min_position_y",map_["min_position_y"]);
|
|
|
- item.put("max_position_y",map_["max_position_y"]);
|
|
|
- item.put("min_position_z",map_["min_position_z"]);
|
|
|
- item.put("max_position_z",map_["max_position_z"]);
|
|
|
+ string xrange = map_["min_position_x"];
|
|
|
+ xrange +=",";
|
|
|
+ xrange+=(map_["max_position_x"]);
|
|
|
+ item.put("xrange",xrange);
|
|
|
+ string yrange = map_["min_position_y"];
|
|
|
+ yrange+=",";
|
|
|
+ yrange+=(map_["max_position_y"]);
|
|
|
+ item.put("yrange",yrange);
|
|
|
+ string zrange = map_["min_position_z"];
|
|
|
+ zrange += ",";
|
|
|
+ zrange+=(map_["max_position_z"]);
|
|
|
+ item.put("zrange",zrange);
|
|
|
item.put("variableName",map_["variableName"]);
|
|
|
- item.put("arearange",map_["arearange"]);
|
|
|
- }else if(type == "update_slice"){
|
|
|
- //to do
|
|
|
+ item.put("areaRange",map_["arearange"]);
|
|
|
+ }else if(type == "create_stream"){
|
|
|
+ item.put("msgType","create_stream_param");
|
|
|
+ item.put("initialStep",map_["initialStep"]);
|
|
|
+ item.put("maxPropagation",map_["maxPropagation"]);
|
|
|
+ item.put("minimumStep",map_["minimumStep"]);
|
|
|
+ }else if(type == "importResult_stream"){
|
|
|
+ item.put("msgType","stream_param");
|
|
|
+ item.put("dataU",map_["dataU"]);
|
|
|
+ item.put("dataV",map_["dataV"]);
|
|
|
+ item.put("dataW",map_["dataW"]);
|
|
|
+ }else if(type == "exception"){
|
|
|
+ item.put("Error",map_["exception"]);
|
|
|
}
|
|
|
stringstream tmp;
|
|
|
json_parser::write_json(tmp,item);
|
|
@@ -164,9 +206,6 @@ string boostJsonObject::ToJson(string type, QMap<QString, string> map_)
|
|
|
stringstream mmsg;
|
|
|
json_parser::write_json (mmsg,root);
|
|
|
return mmsg.str();
|
|
|
-
|
|
|
- //boost::json::object json_obj;
|
|
|
-
|
|
|
}
|
|
|
|
|
|
/*
|
|
@@ -182,54 +221,117 @@ void boostJsonObject::FromParamJson(string param)
|
|
|
params<<param;
|
|
|
ptree root;
|
|
|
read_json(params,root);
|
|
|
- try{
|
|
|
+
|
|
|
+ if(this->action == "loaddata"){
|
|
|
+ this->filePath = root.get<string>("filePath");
|
|
|
+ }
|
|
|
+ if(this->action == "ResultImport"){
|
|
|
this->filePath = root.get<string>("filePath");
|
|
|
this->fileType = root.get<string>("fileType");
|
|
|
this->fileName = root.get<string>("fileName");
|
|
|
- if(this->action == "ContourDisplay"){
|
|
|
- this->cd_struct = new contourDisplay_struct();
|
|
|
- cd_struct->level = root.get<int>("level");
|
|
|
- QString range = QString::fromStdString(root.get<string>("range"));
|
|
|
- QStringList range_list = range.split(",");
|
|
|
- cd_struct->range[0] = range_list[0].toDouble();
|
|
|
- cd_struct->range[1] = range_list[1].toDouble();
|
|
|
- cd_struct->scalarName = root.get<string>("scalarName");
|
|
|
- }else if(this->action == "LineDisplay"){
|
|
|
- this->ld_struct = new contourDisplay_struct();
|
|
|
- ld_struct->level = root.get<int>("level");
|
|
|
- QString range = QString::fromStdString(root.get<string>("range"));
|
|
|
- QStringList range_list = range.split(",");
|
|
|
- ld_struct->range[0] = range_list[0].toDouble();
|
|
|
- ld_struct->range[1] = range_list[1].toDouble();
|
|
|
- ld_struct->scalarName = root.get<string>("scalarName");
|
|
|
- }else if(this->action == "VectorDisplay"){
|
|
|
- vc_struct = new vectorDisplay_struct();
|
|
|
- vc_struct->dataU = root.get<string>("dataU");
|
|
|
- vc_struct->dataV = root.get<string>("dataV");
|
|
|
- vc_struct->dataW = root.get<string>("dataW");
|
|
|
- vc_struct->scaleFactor = root.get<double>("scaleFactor");
|
|
|
- }else if(this->action == "SolidSurfaceDisplay"){
|
|
|
- sf_struct = new solidsurfaceDisplay_struct();
|
|
|
- sf_struct->r = root.get<double>("r");
|
|
|
- sf_struct->g = root.get<double>("g");
|
|
|
- sf_struct->b = root.get<double>("b");
|
|
|
- sf_struct->transparency = root.get<double>("transparency");
|
|
|
- sf_struct->showhidestate = root.get<bool>("showHideState");
|
|
|
- }else if(this->action == "SliceDisplayAdd"){
|
|
|
- sd_struct = new sliceDisplay_struct();
|
|
|
- sd_struct->index = root.get<double>("index");
|
|
|
- }else if(this->action == "SliceDisplayUpdate"){
|
|
|
- //do nothing
|
|
|
- }else if(this->action == "SliceDisplayDel"){
|
|
|
+ }
|
|
|
+ if(this->action == "ContourDisplay"){
|
|
|
+ this->cd_struct = new contourDisplay_struct();
|
|
|
+ cd_struct->level = root.get<int>("level");
|
|
|
+ QString range = QString::fromStdString(root.get<string>("range"));
|
|
|
+ QStringList range_list = range.split(",");
|
|
|
+ cd_struct->range[0] = range_list[0].toDouble();
|
|
|
+ cd_struct->range[1] = range_list[1].toDouble();
|
|
|
+ cd_struct->scalarName = root.get<string>("scalarName");
|
|
|
+ }else if(this->action == "LineDisplay"){
|
|
|
+ this->ld_struct = new contourDisplay_struct();
|
|
|
+ ld_struct->level = root.get<int>("level");
|
|
|
+ QString range = QString::fromStdString(root.get<string>("range"));
|
|
|
+ QStringList range_list = range.split(",");
|
|
|
+ ld_struct->range[0] = range_list[0].toDouble();
|
|
|
+ ld_struct->range[1] = range_list[1].toDouble();
|
|
|
+ ld_struct->scalarName = root.get<string>("scalarName");
|
|
|
+ }else if(this->action == "VectorDisplay"){
|
|
|
+ vc_struct = new vectorDisplay_struct();
|
|
|
+ vc_struct->dataU = root.get<string>("dataU");
|
|
|
+ vc_struct->dataV = root.get<string>("dataV");
|
|
|
+ vc_struct->dataW = root.get<string>("dataW");
|
|
|
+ vc_struct->scaleFactor = root.get<double>("scaleFactor");
|
|
|
+ }else if(this->action == "SolidSurfaceDisplay"){
|
|
|
+ sf_struct = new solidsurfaceDisplay_struct();
|
|
|
+ sf_struct->r = root.get<double>("r");
|
|
|
+ sf_struct->g = root.get<double>("g");
|
|
|
+ sf_struct->b = root.get<double>("b");
|
|
|
+ sf_struct->transparency = root.get<double>("transparency");
|
|
|
+ sf_struct->showhidestate = root.get<bool>("showHideState");
|
|
|
+ }else if(this->action == "SliceDisplayAdd"){
|
|
|
+ try{
|
|
|
sd_struct = new sliceDisplay_struct();
|
|
|
sd_struct->index = root.get<double>("index");
|
|
|
- }else if(this->action == "SliceDisplayApply"){
|
|
|
- //to do
|
|
|
+ sd_struct->index = sd_struct->index-1;
|
|
|
+ }catch(exception ex){
|
|
|
+ throw ex;
|
|
|
+ return;
|
|
|
}
|
|
|
- }catch(exception ex){
|
|
|
- cout<<ex.what()<<endl;;
|
|
|
- return;
|
|
|
+ }else if(this->action == "SliceDisplayUpdate"){
|
|
|
+ //do nothing
|
|
|
+ }else if(this->action == "SliceDisplayDel"){
|
|
|
+ sd_struct = new sliceDisplay_struct();
|
|
|
+ sd_struct->index = root.get<double>("index");
|
|
|
+ sd_struct->index = sd_struct->index - 1;
|
|
|
+ }else if(this->action == "StreamDisplayCreate"){
|
|
|
+ sm_struct = new streamDisplay_struct();
|
|
|
+ sm_struct->u = root.get<string>("u");
|
|
|
+ sm_struct->v = root.get<string>("v");
|
|
|
+ sm_struct->w = root.get<string>("w");
|
|
|
+ }else if(this->action == "StreamDisplaySelect"){
|
|
|
+ //do nothing
|
|
|
+ }else if(this->action == "StreamDisplayDeleteLast"){
|
|
|
+ //do nothing
|
|
|
+ }else if(this->action == "StreamDisplayDeleteAll"){
|
|
|
+ //do nothing
|
|
|
+ }else if(this->action == "StreamDisplayApply"){
|
|
|
+ sm_struct = new streamDisplay_struct();
|
|
|
+ sm_struct->direction = root.get<string>("direction");
|
|
|
+ sm_struct->streamstyle = root.get<string>("streamstyle");
|
|
|
+ sm_struct->initialstep = root.get<double>("initialstep");
|
|
|
+ sm_struct->maxpropagation = root.get<double>("maxpropagation");
|
|
|
+ sm_struct->minimumstep = root.get<double>("minimumstep");
|
|
|
+ sm_struct->showstate = root.get<bool>("showstate");
|
|
|
+ sm_struct->toolstate = root.get<bool>("toolstate");
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+ * @brief: to json
|
|
|
+ * @param: map
|
|
|
+ * @ret: void
|
|
|
+ * @birth: created by czm in 20230508
|
|
|
+ */
|
|
|
+string boostJsonObject::ToJson_updateslice(QMap<int, SliceDisplayWidget *>map_)
|
|
|
+{
|
|
|
+ ptree root;
|
|
|
+ root.put("usrId",this->usrId);
|
|
|
+ root.put("solverConfigid",this->solverConfigid);
|
|
|
+ root.put("proId",this->proId);
|
|
|
+ root.put("action",this->action);
|
|
|
+ ptree children;
|
|
|
+ for(auto iter = map_.begin();iter!=map_.end();iter++){
|
|
|
+ ptree child;
|
|
|
+ child.put("index",iter.key()+1);
|
|
|
+ child.put("normal_x",iter.value()->GetNormal()[0]);
|
|
|
+ child.put("normal_y",iter.value()->GetNormal()[1]);
|
|
|
+ child.put("normal_z",iter.value()->GetNormal()[2]);
|
|
|
+ child.put("position_x",iter.value()->GetPosition()[0]);
|
|
|
+ child.put("position_y",iter.value()->GetPosition()[1]);
|
|
|
+ child.put("position_z",iter.value()->GetPosition()[2]);
|
|
|
+ children.push_back(make_pair("",child));
|
|
|
}
|
|
|
+ ptree pt;
|
|
|
+ pt.add_child("update_param", children);
|
|
|
+ stringstream tmp_;
|
|
|
+ json_parser::write_json(tmp_,pt);
|
|
|
+ root.put("paramJson",tmp_.str());
|
|
|
+
|
|
|
+ stringstream mmsg;
|
|
|
+ json_parser::write_json (mmsg,root);
|
|
|
+ return mmsg.str();
|
|
|
}
|
|
|
|
|
|
|