MCPcopy Create free account
hub / github.com/Kitware/ParaView / initializeUsingJSON

Method initializeUsingJSON

Qt/Components/pqCameraKeyFrameWidget.cxx:207–273  ·  view source on GitHub ↗

-----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

205
206//-----------------------------------------------------------------------------
207void pqCameraKeyFrameWidget::initializeUsingJSON(const Json::Value& json)
208{
209 std::vector<double> value;
210 auto parseJSONVector = [&json, &value](const char* name, unsigned int size) -> bool
211 {
212 value.resize(size);
213 for (unsigned int idx = 0; idx < size; idx++)
214 {
215 if (json[name][idx].isDouble())
216 {
217 value[idx] = json[name][idx].asDouble();
218 }
219 else
220 {
221 return false;
222 }
223 }
224 return true;
225 };
226
227 if (json["viewUp"].size() == 3 && parseJSONVector("viewUp", 3))
228 {
229 this->Internal->setViewUp(value.data());
230 }
231 if (this->usePathBasedMode())
232 {
233 unsigned int size = json["positions"].size();
234 if (size >= 3 && size % 3 == 0 && parseJSONVector("positions", size))
235 {
236 vtkSMPropertyHelper(this->Internal->PSplineProxy, "Points").Set(value.data(), size);
237 }
238 size = json["focalPoints"].size();
239 if (size >= 3 && size % 3 == 0 && parseJSONVector("focalPoints", size))
240 {
241 vtkSMPropertyHelper(this->Internal->FSplineProxy, "Points").Set(value.data(), size);
242 }
243 if (json["positionPathClosed"].isInt())
244 {
245 vtkSMPropertyHelper(this->Internal->PSplineProxy, "Closed")
246 .Set(json["positionPathClosed"].asInt());
247 }
248 if (json["focalPointPathClosed"].isInt())
249 {
250 vtkSMPropertyHelper(this->Internal->FSplineProxy, "Closed")
251 .Set(json["focalPointPathClosed"].asInt());
252 }
253 }
254 else
255 {
256 if (json["position"].size() == 3 && parseJSONVector("position", 3))
257 {
258 this->Internal->setPosition(value.data());
259 }
260 if (json["focalPoint"].size() == 3 && parseJSONVector("focalPoint", 3))
261 {
262 this->Internal->setFocalPoint(value.data());
263 }
264 if (json["viewAngle"].isDouble())

Callers

nothing calls this directly

Calls 10

usePathBasedModeMethod · 0.95
setPositionMethod · 0.80
setFocalPointMethod · 0.80
setViewAngleMethod · 0.80
resizeMethod · 0.45
sizeMethod · 0.45
setViewUpMethod · 0.45
dataMethod · 0.45
SetMethod · 0.45
setParallelScaleMethod · 0.45

Tested by

no test coverage detected