Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
REveCamera.cxx
Go to the documentation of this file.
1// @(#)root/eve7:$Id$
2// Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007, 2018
3
4/*************************************************************************
5 * Copyright (C) 1995-2019, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#include <ROOT/REveCamera.hxx>
13#include <ROOT/REveManager.hxx>
14
15#include <nlohmann/json.hpp>
16#include <iostream>
17
18using namespace ROOT::Experimental;
19
20////////////////////////////////////////////////////////////////////////////////
21/// Default constructor
22
24{
25 Setup(kCameraPerspXOZ, "PerspXOZ", REveVector(-1.0, 0.0, 0.0), REveVector(0.0, 1.0, 0.0));
28}
29
30////////////////////////////////////////////////////////////////////////////////
31/// Constructor with name
32
34{
35 Setup(kCameraPerspXOZ, name, REveVector(-1.0, 0.0, 0.0), REveVector(0.0, 1.0, 0.0));
38}
39
40////////////////////////////////////////////////////////////////////////////////
41/// Setup camera with type, name, direction and up vectors
42
43void REveCamera::Setup(ECameraType type, const std::string &name, const REveVector &hAxis, const REveVector &vAxis)
44{
45 fType = type;
46 fName = name;
47
48 // Set up base camera matrix from direction and up vectors
51
52 fCamBase.SetBaseVec(1, hAxis.fX, hAxis.fY, hAxis.fZ);
53 fCamBase.SetBaseVec(3, vAxis.fX, vAxis.fY, vAxis.fZ);
54
55 REveVector y = vAxis.Cross(hAxis);
56 fCamBase.SetBaseVec(2, y.fX, y.fY, y.fZ);
57
59}
60
61////////////////////////////////////////////////////////////////////////////////
62/// Set camera base matrix from array (called from client via MIR)
63
64void REveCamera::SetCamBaseMtx(const std::vector<Double_t> &arr)
65{
66 if (arr.size() == 16) {
69 }
70}
71
72void REveCamera::SetCamBaseMtx(const std::string &json_str)
73{
74 auto j = nlohmann::json::parse(json_str);
75 std::vector<Double_t> arr = j.get<std::vector<Double_t>>();
77}
78
79void REveCamera::SetCamTransMtx(const std::vector<Double_t> &arr)
80{
81 if (arr.size() == 16) {
84 }
85}
86
87// Set translation matrix with an array of 17 floats
88// The first 16 floats are 4x4 matrix element
89// The 17th value is setting the zoom value in orthographic type
91{
92 std::stringstream ss(ins);
93 std::vector<double> arr;
94 std::string item;
95 while (std::getline(ss, item, ',')) {
96 arr.push_back(std::stod(item));
97 }
98
99 fOrthoZoom = arr.back();
100 arr.pop_back();
101 fCamTrans.SetFromArray(arr.data());
102
103 fInitialized = true;
104
107}
108
110{
112}
113
114////////////////////////////////////////////////////////////////////////////////
115/// Write core JSON for camera
116
118{
120
121 j["fType"] = fType;
122 j["fName"] = fName;
123 j["fInitialized"] = fInitialized; // Stream to client
124
125 // Stream both matrices
126 // Client will read these as fMatrix arrays (16 elements each)
128 j["camBase"] = std::vector<Double_t>(camBaseArr, camBaseArr + 16);
129
131 j["camTrans"] = std::vector<Double_t>(camTransArr, camTransArr + 16);
132 j["fZoom"] = fOrthoZoom;
133
134 return ret;
135}
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
char name[80]
Definition TGX11.cxx:148
void SetCamTransMtxStr(const char *json_str)
Int_t WriteCoreJson(nlohmann::json &j, Int_t rnr_offset) override
Write core JSON for camera.
REveCamera()
Default constructor.
void Setup(ECameraType type, const std::string &name, const REveVector &v1, const REveVector &v2)
Setup camera with type, name, direction and up vectors.
void SetCamBaseMtx(const std::vector< Double_t > &arr)
Set camera base matrix from array (called from client via MIR)
void SetCamTransMtx(const std::vector< Double_t > &arr)
virtual Int_t WriteCoreJson(nlohmann::json &cj, Int_t rnr_offset)
Write core json.
void SetFromArray(const Double_t arr[16])
Set matrix from Double_t array.
void SetBaseVec(Int_t b, Double_t x, Double_t y, Double_t z)
Set base-vector with index b.
void UnitTrans()
Reset matrix to unity.
Double_t y[n]
Definition legend1.C:17
Namespace for ROOT features in testing.
Definition TROOT.h:100
REveVectorT< Float_t > REveVector