void ZFlyEmMisc::HackathonEvaluator::processNeuronTypeFile() { ZJsonObject jsonObject; jsonObject.load(getNeuronInfoFile()); const char *key; json_t *value; std::map<std::string, int> typeLabelMap; std::vector<int> bodyIdArray; std::vector<int> labelArray; int maxLabel = 0; ZJsonArray idJson; ZJsonArray labelJson; ZJsonObject_foreach(jsonObject, key, value) { int bodyId = ZString(key).firstInteger(); ZJsonObject bodyJson(value, ZJsonValue::SET_INCREASE_REF_COUNT); std::string type = ZJsonParser::stringValue(bodyJson["Type"]); if (typeLabelMap.count(type) == 0) { typeLabelMap[type] = ++maxLabel; } int label = typeLabelMap[type]; bodyIdArray.push_back(bodyId); labelArray.push_back(label); idJson.append(bodyId); labelJson.append(label); }
ZJsonObject ZDvidTarget::toJsonObject() const { ZJsonObject obj = m_node.toJsonObject(); obj.setNonEmptyEntry(m_commentKey, m_comment); obj.setNonEmptyEntry(m_nameKey, m_name); obj.setNonEmptyEntry(m_localKey, m_localFolder); obj.setEntry(m_bgValueKey, m_bgValue); obj.setNonEmptyEntry(m_bodyLabelNameKey, m_bodyLabelName); obj.setNonEmptyEntry(m_segmentationNameKey, m_segmentationName); obj.setEntry(m_maxLabelZoomKey, m_maxLabelZoom); obj.setEntry(m_maxGrayscaleZoomKey, getMaxGrayscaleZoom()); obj.setNonEmptyEntry(m_grayScaleNameKey, m_grayScaleName); obj.setNonEmptyEntry(m_synapseLabelszKey, m_synapseLabelszName); obj.setNonEmptyEntry(m_roiNameKey, m_roiName); obj.setNonEmptyEntry(m_todoListNameKey, m_todoListName); obj.setEntry(m_proofreadingKey, !m_readOnly); ZJsonArray jsonArray; for (std::vector<std::string>::const_iterator iter = m_roiList.begin(); iter != m_roiList.end(); ++iter) { jsonArray.append(*iter); } obj.setEntry(m_roiListKey, jsonArray); obj.setEntry(m_multiscale2dNameKey, m_multiscale2dName); if (!m_tileConfig.empty()) { /* ZJsonObject tileConfigJson; for (const auto& tg : m_tileConfig) { ZJsonObject subjson = tg.second.toJsonObject(); tileConfigJson.setEntry(tg.first.c_str(), subjson); } */ ZJsonObject tileConfigJson = MakeJsonObject(m_tileConfig); obj.setEntry(m_tileConfigKey, tileConfigJson); } /* if (!m_tileConfig.isEmpty()) { obj.setEntry(m_tileConfigKey, const_cast<ZJsonObject&>(m_tileConfig)); } */ if (!m_sourceConfig.empty()) { ZJsonObject sourceConfigJson = MakeJsonObject(m_sourceConfig); obj.setEntry(m_sourceConfigKey, sourceConfigJson); // obj.setEntry(m_sourceConfigKey, const_cast<ZJsonObject&>(m_sourceConfig)); } obj.setEntry(m_synapseNameKey, m_synapseName); obj.setEntry(m_supervisorKey, m_isSupervised); obj.setEntry(m_supervisorServerKey, m_supervisorServer); obj.setEntry(m_defaultSettingKey, usingDefaultDataSetting()); return obj; }
std::vector<std::string> ZFlyEmSupervisor::getUuidList() const { ZDvidBufferReader reader; reader.read(getUuidsUrl().c_str()); const QByteArray &buffer = reader.getBuffer(); std::vector<std::string> uuidList; if (!buffer.isEmpty()) { ZJsonArray obj; obj.decodeString(buffer.constData()); for (size_t i = 0; i < obj.size(); ++i) { uuidList.push_back(ZJsonParser::stringValue(obj.at(i))); } } return uuidList; // reader.read(ZDvidUrl) }
ZJsonObject Z3DCamera::toJsonObject() const { ZJsonObject cameraJson; ZJsonArray eyeJson; eyeJson.append(m_eye[0]); eyeJson.append(m_eye[1]); eyeJson.append(m_eye[2]); cameraJson.setEntry("eye", eyeJson); ZJsonArray centerJson; centerJson.append(m_center[0]); centerJson.append(m_center[1]); centerJson.append(m_center[2]); cameraJson.setEntry("center", centerJson); ZJsonArray upVectorJson; upVectorJson.append(m_upVector[0]); upVectorJson.append(m_upVector[1]); upVectorJson.append(m_upVector[2]); cameraJson.setEntry("up_vector", upVectorJson); switch (m_projectionType) { case Perspective: cameraJson.setEntry("projection", std::string("Perspective")); break; case Orthographic: cameraJson.setEntry("projection", std::string("Orthographic")); break; } cameraJson.setEntry("field_of_view", m_fieldOfView); cameraJson.setEntry("aspect_ratio", m_aspectRatio); cameraJson.setEntry("near_dist", m_nearDist); cameraJson.setEntry("far_dist", m_farDist); return cameraJson; }
void ZMovieScene::loadJsonObject(const ZJsonObject &obj) { m_actionList.clear(); map<string, json_t*> entryMap = obj.toEntryMap(); for (map<string, json_t*>::const_iterator iter = entryMap.begin(); iter != entryMap.end(); ++iter) { #ifdef _DEBUG_2 cout << "Scene key: " << iter->first << endl; #endif if (isDurationTag(iter->first.c_str())) { setDuration(ZJsonParser::numberValue(iter->second)); } else if (isBackgroundTag(iter->first.c_str())) { setBackground(ZJsonParser::booleanValue(iter->second)); } else if (isActionListTag(iter->first.c_str())) { ZJsonArray actionList; TZ_ASSERT(ZJsonParser::isArray(iter->second), "array"); actionList.set(iter->second, false); for (size_t index = 0; index < actionList.size(); ++index) { ZJsonObject actionObject(actionList.at(index), false); map<string, json_t*> actionEntry = actionObject.toEntryMap(); MovieAction action; for (std::map<string, json_t*>::const_iterator actionIter = actionEntry.begin(); actionIter != actionEntry.end(); ++actionIter) { if (isIdTag(actionIter->first.c_str())) { action.actorId = ZJsonParser::stringValue(actionIter->second); } else if (isVisibleTag(actionIter->first.c_str())) { action.isVisible = ZJsonParser::booleanValue(actionIter->second); } else if (isMovingTag(actionIter->first.c_str())) { action.movingOffset.setX( ZJsonParser::numberValue(actionIter->second, 0)); action.movingOffset.setY( ZJsonParser::numberValue(actionIter->second, 1)); action.movingOffset.setZ( ZJsonParser::numberValue(actionIter->second, 2)); } else if (isColorTag(actionIter->first.c_str())) { action.settingColor = true; action.red = ZJsonParser::numberValue(actionIter->second, 0); action.green = ZJsonParser::numberValue(actionIter->second, 1); action.blue = ZJsonParser::numberValue(actionIter->second, 2); } else if (isAlphaTag(actionIter->first.c_str())) { action.settingAlpha = true; action.alpha = ZJsonParser::numberValue(actionIter->second); } else if (isFadingTag(actionIter->first.c_str())) { action.fadingFactor = ZJsonParser::numberValue(actionIter->second); } else if (isTransitTag(actionIter->first.c_str())) { if (ZJsonParser::isNumber(actionIter->second)) { action.transitFactor[0] = ZJsonParser::numberValue(actionIter->second); action.transitFactor[1] = action.transitFactor[0]; action.transitFactor[2] = action.transitFactor[1]; } else if (ZJsonParser::isArray(actionIter->second)){ action.transitFactor[0] = ZJsonParser::numberValue(actionIter->second, 0); action.transitFactor[1] = ZJsonParser::numberValue(actionIter->second, 1); action.transitFactor[2] = ZJsonParser::numberValue(actionIter->second, 2); } } } addAction(action); } } else if (isCameraTag(iter->first.c_str())) { ZJsonObject cameraObject(iter->second, false); m_camera.loadJsonObject(cameraObject); /* json_t *rotationObj = cameraObject["rotate"]; if (rotationObj != NULL) { m_cameraRotation.loadJsonObject(ZJsonObject(rotationObj, false)); } */ } else if (isClipperTag(iter->first.c_str())) { for (size_t i = 0; i < ZJsonParser::arraySize(iter->second); ++i) { ZJsonObject clipperObject(ZJsonParser::arrayValue(iter->second, i), false); ZMovieSceneClipper clipper; clipper.loadJsonObject(clipperObject); m_clipperArray.push_back(clipper); } } } }