LVRRecordedFrameItem.cpp
Go to the documentation of this file.
1 
28 #include "LVRRecordedFrameItem.hpp"
29 #include "LVRItemTypes.hpp"
30 
31 namespace lvr2
32 {
33 
34 // Create a camera from the current frame
35 LVRRecordedFrameItem::LVRRecordedFrameItem(vtkSmartPointer<vtkCameraRepresentation> pathCamera, QString name) :
36  m_name(name)
37 {
38  // Setup item properties
39  setText(m_name);
40 
41  m_recordedFrame = vtkSmartPointer<vtkCamera>::New();
42  m_recordedFrame->DeepCopy(pathCamera->GetCamera());
43 }
44 
45 // Create a camera without setting its properties
47  m_name(name)
48 {
49  // Setup item properties
50  setText(m_name);
51 
52  m_recordedFrame = vtkSmartPointer<vtkCamera>::New();
53 }
54 
56 {
57  // TODO Auto-generated destructor stub
58 }
59 
60 vtkSmartPointer<vtkCamera> LVRRecordedFrameItem::getFrame()
61 {
62  return m_recordedFrame;
63 }
64 
66 {
67  // Save the position, the focal point and the view up to the current text stream
68  out << "C:" << m_name << ";";
69  double* position = m_recordedFrame->GetPosition();
70  out << position[0] << "," << position[1] << "," << position[2] << ";";
71  double* focalPoint = m_recordedFrame->GetFocalPoint();
72  out << focalPoint[0] << "," << focalPoint[1] << "," << focalPoint[2] << ";";
73  double* viewUp = m_recordedFrame->GetViewUp();
74  out << viewUp[0] << "," << viewUp[1] << "," << viewUp[2] << endl;
75 }
76 
78 {
79  QString line = in.readLine();
80  // TODO: Surround with try and catch to prevent errors
81  // Very basic file validity checking
82  if(!line.startsWith("C:"))
83  {
84  cout << "Couldn't read frame from file!" << endl;
85  return NULL;
86  }
87 
88  line.remove(0,2);
89  QStringList parameters = line.trimmed().split(";");
90 
91  QString name = parameters[0];
92  LVRRecordedFrameItem* recordedFrameItem = new LVRRecordedFrameItem(name);
93 
94  QStringList position = parameters[1].split(",");
95  recordedFrameItem->getFrame()->SetPosition(position[0].toDouble(), position[1].toDouble(), position[2].toDouble());
96 
97  QStringList focalPoint = parameters[2].split(",");
98  recordedFrameItem->getFrame()->SetFocalPoint(focalPoint[0].toDouble(), focalPoint[1].toDouble(), focalPoint[2].toDouble());
99 
100  QStringList viewUp = parameters[3].split(",");
101  recordedFrameItem->getFrame()->SetViewUp(viewUp[0].toDouble(), viewUp[1].toDouble(), viewUp[2].toDouble());
102 
103  return recordedFrameItem;
104 }
105 
106 } /* namespace lvr2 */
lvr2::LVRRecordedFrameItem::LVRRecordedFrameItem
LVRRecordedFrameItem(vtkSmartPointer< vtkCameraRepresentation > pathCamera, QString name="")
Definition: LVRRecordedFrameItem.cpp:35
lvr2::LVRRecordedFrameItem::getFrame
vtkSmartPointer< vtkCamera > getFrame()
Definition: LVRRecordedFrameItem.cpp:60
lvr2::LVRRecordedFrameItem::m_name
QString m_name
Definition: LVRRecordedFrameItem.hpp:58
LVRItemTypes.hpp
NULL
#define NULL
Definition: mydefs.hpp:141
lvr2::LVRRecordedFrameItem
Definition: LVRRecordedFrameItem.hpp:43
lvr2::LVRRecordedFrameItem::createFromStream
static LVRRecordedFrameItem * createFromStream(QTextStream &in)
Definition: LVRRecordedFrameItem.cpp:77
LVRRecordedFrameItem.hpp
lvr2::LVRRecordedFrameItem::writeToStream
void writeToStream(QTextStream &out)
Definition: LVRRecordedFrameItem.cpp:65
lvr2::LVRRecordedFrameItem::~LVRRecordedFrameItem
virtual ~LVRRecordedFrameItem()
Definition: LVRRecordedFrameItem.cpp:55
lvr2
Definition: BaseBufferManipulators.hpp:39
lvr2::LVRRecordedFrameItem::m_recordedFrame
vtkSmartPointer< vtkCamera > m_recordedFrame
Definition: LVRRecordedFrameItem.hpp:57


lvr2
Author(s): Thomas Wiemann , Sebastian Pütz , Alexander Mock , Lars Kiesow , Lukas Kalbertodt , Tristan Igelbrink , Johan M. von Behren , Dominik Feldschnieders , Alexander Löhr
autogenerated on Wed Mar 2 2022 00:37:24