Merge lp:~jocke-karlsson/forssim/playbackStart into lp:forssim

Proposed by jocke
Status: Merged
Merged at revision: not available
Proposed branch: lp:~jocke-karlsson/forssim/playbackStart
Merge into: lp:forssim
Diff against target: None lines
To merge this branch: bzr merge lp:~jocke-karlsson/forssim/playbackStart
Reviewer Review Type Date Requested Status
Forsslund Systems Pending
Review via email: mp+7241@code.launchpad.net
To post a comment you must log in.
Revision history for this message
jocke (jocke-karlsson) wrote :

Nerladdningen av timestamp fil sker först när användaren trycker på Playback knappen.
Vid exit från playback mode skall statistik ej sparas.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'FsWisdom/ApplicationNode.cpp'
2--- FsWisdom/ApplicationNode.cpp 2009-06-09 07:51:35 +0000
3+++ FsWisdom/ApplicationNode.cpp 2009-06-09 14:25:42 +0000
4@@ -324,99 +324,120 @@
5 void ApplicationNode::exitX3DWithStandardGuiWindow()
6 {
7 glWindow->stopTimer();
8-
9- switch(QMessageBox::question(NULL,tr("Save Data on Exit"),
10- tr("Do you wish to save the data associated with this case?"),
11- QMessageBox::Yes|QMessageBox::No|QMessageBox::Cancel,QMessageBox::Yes))
12- {
13- case QMessageBox::Yes:
14- // save timestamps
15- this->setOverrideCursor(QCursor(Qt::WaitCursor));
16- volumeModel = static_cast <VolumeModel*> (glWindow->getSceneNode("VM"));
17- materialSegmentationModel = static_cast< MaterialSegmentationModel * >(glWindow->getSceneNode("SM"));
18-
19- //Number of Forbidden voxels
20- forbiddenSegmentationModel = static_cast< ForbiddenSegmentationModel * >(glWindow->getSceneNode("FM"));
21-
22-
23- volumeModel->saveTimeStamps();
24- volumeModel->saveStatistics();
25-
26- // Save user case to database
27- if(forsDatabase.open())
28- {
29- QSqlQuery query;
30-
31- query.prepare("INSERT INTO userCase (userId, forsCaseVersionId, timeStampFile) "
32- "VALUES (:userId, :forsCaseVersionId, :timeStampFile)");
33- query.bindValue(":userId", userId);
34- query.bindValue(":forsCaseVersionId", forsCaseVersionId);
35- QFile file( QDir( QString (volumeModel->saveTimeStamps().c_str()) ).path() );
36- file.open(QIODevice::ReadOnly);
37- QByteArray byteArray = file.readAll();
38- query.bindValue(":timeStampFile", byteArray);
39-
40- if(query.exec())
41- cout << "Added recorded data to database" << endl;
42- else
43- throw ApplicationNodeException("Failed to add recorded data to database");
44-
45- MFUnsignedInt8::const_iterator segmentIdFieldIterator;
46-
47- query.prepare("SELECT LAST_INSERT_ID()");
48- if(!query.exec())
49- throw ApplicationNodeException("Failed to read last index from database");
50- query.next();
51- int index = query.value(0).toInt();
52-
53- for(segmentIdFieldIterator=forbiddenSegmentationModel->segmentIdField->begin();
54- segmentIdFieldIterator<forbiddenSegmentationModel->segmentIdField->end();
55- segmentIdFieldIterator++)
56+ cout << "exitX3DWithStandardGuiWindow" <<endl;
57+ if (this->isPlayback)
58+ {
59+ switch(QMessageBox::question(NULL,tr("Do you want to Exit"),
60+ tr("Do you want to Exit?"),
61+ QMessageBox::Yes|QMessageBox::Cancel,QMessageBox::Yes))
62+ {
63+ case QMessageBox::Yes:
64+ // back to select case menu
65+ glWindow->close();
66+ selectCaseWindow->setGeometry(QApplication::desktop()->availableGeometry(0));
67+ selectCaseWindow->showFullScreen();
68+ removeWisdomToothWindow->close();
69+ return;
70+ default:
71+ glWindow->startTimer();
72+ return;
73+ }
74+ }
75+ else
76+ {
77+ switch(QMessageBox::question(NULL,tr("Save Data on Exit"),
78+ tr("Do you wish to save the data associated with this case?"),
79+ QMessageBox::Yes|QMessageBox::No|QMessageBox::Cancel,QMessageBox::Yes))
80+ {
81+ case QMessageBox::Yes:
82+ // save timestamps
83+ this->setOverrideCursor(QCursor(Qt::WaitCursor));
84+ volumeModel = static_cast <VolumeModel*> (glWindow->getSceneNode("VM"));
85+ materialSegmentationModel = static_cast< MaterialSegmentationModel * >(glWindow->getSceneNode("SM"));
86+
87+ //Number of Forbidden voxels
88+ forbiddenSegmentationModel = static_cast< ForbiddenSegmentationModel * >(glWindow->getSceneNode("FM"));
89+
90+
91+ volumeModel->saveTimeStamps();
92+ volumeModel->saveStatistics();
93+
94+ // Save user case to database
95+ if(forsDatabase.open())
96 {
97- query.prepare("INSERT INTO segments (userCaseId, segmentId, voxelsRemoved) "
98- "VALUES (:userCaseId, :segmentId, :voxelsRemoved)");
99- query.bindValue(":userCaseId", index );
100- query.bindValue(":segmentId", -(*segmentIdFieldIterator));
101- query.bindValue(":voxelsRemoved", forbiddenSegmentationModel->noOfVoxelsBoredByUser->getValue()[(*segmentIdFieldIterator)]);
102- if(query.exec())
103- cout << "Added forbidden segment data to database" << endl;
104- else
105- cout << "No forbidden segments added to database" << endl;
106-
107- cout << query.lastError().databaseText ().toStdString()<< endl;
108- }
109-
110-
111- int noOfSegments = materialSegmentationModel->getNoOfSegments();
112- for (int i = 1;i<noOfSegments;i++){
113- query.prepare("INSERT INTO segments (userCaseId, segmentId, voxelsRemoved) "
114- "VALUES (:userCaseId, :segmentId, :voxelsRemoved)");
115- query.bindValue(":userCaseId", index );
116- query.bindValue(":segmentId", i);
117- query.bindValue(":voxelsRemoved", volumeModel->noOfVoxelsRemoved(i));
118-
119- if(query.exec())
120- cout << "Added segment data to database" << endl;
121- else
122- cout << "No segments added to database" << endl;
123-
124- cout << query.lastError().databaseText ().toStdString()<< endl;
125- }
126-
127+ QSqlQuery query;
128+
129+ query.prepare("INSERT INTO userCase (userId, forsCaseVersionId, timeStampFile) "
130+ "VALUES (:userId, :forsCaseVersionId, :timeStampFile)");
131+ query.bindValue(":userId", userId);
132+ query.bindValue(":forsCaseVersionId", forsCaseVersionId);
133+ QFile file( QDir( QString (volumeModel->saveTimeStamps().c_str()) ).path() );
134+ file.open(QIODevice::ReadOnly);
135+ QByteArray byteArray = file.readAll();
136+ query.bindValue(":timeStampFile", byteArray);
137+
138+ if(query.exec())
139+ cout << "Added recorded data to database" << endl;
140+ else
141+ throw ApplicationNodeException("Failed to add recorded data to database");
142+
143+ MFUnsignedInt8::const_iterator segmentIdFieldIterator;
144+
145+ query.prepare("SELECT LAST_INSERT_ID()");
146+ if(!query.exec())
147+ throw ApplicationNodeException("Failed to read last index from database");
148+ query.next();
149+ int index = query.value(0).toInt();
150+
151+ for(segmentIdFieldIterator=forbiddenSegmentationModel->segmentIdField->begin();
152+ segmentIdFieldIterator<forbiddenSegmentationModel->segmentIdField->end();
153+ segmentIdFieldIterator++)
154+ {
155+ query.prepare("INSERT INTO segments (userCaseId, segmentId, voxelsRemoved) "
156+ "VALUES (:userCaseId, :segmentId, :voxelsRemoved)");
157+ query.bindValue(":userCaseId", index );
158+ query.bindValue(":segmentId", -(*segmentIdFieldIterator));
159+ query.bindValue(":voxelsRemoved", forbiddenSegmentationModel->noOfVoxelsBoredByUser->getValue()[(*segmentIdFieldIterator)]);
160+ if(query.exec())
161+ cout << "Added forbidden segment data to database" << endl;
162+ else
163+ cout << "No forbidden segments added to database" << endl;
164+
165+ cout << query.lastError().databaseText ().toStdString()<< endl;
166+ }
167+
168+
169+ int noOfSegments = materialSegmentationModel->getNoOfSegments();
170+ for (int i = 1;i<noOfSegments;i++){
171+ query.prepare("INSERT INTO segments (userCaseId, segmentId, voxelsRemoved) "
172+ "VALUES (:userCaseId, :segmentId, :voxelsRemoved)");
173+ query.bindValue(":userCaseId", index );
174+ query.bindValue(":segmentId", i);
175+ query.bindValue(":voxelsRemoved", volumeModel->noOfVoxelsRemoved(i));
176+
177+ if(query.exec())
178+ cout << "Added segment data to database" << endl;
179+ else
180+ cout << "No segments added to database" << endl;
181+
182+ cout << query.lastError().databaseText ().toStdString()<< endl;
183+ }
184+
185+ }
186+
187+ this->restoreOverrideCursor();
188+ // falls down into no
189+ case QMessageBox::No:
190+ // back to select case menu
191+ glWindow->close();
192+ selectCaseWindow->setGeometry(QApplication::desktop()->availableGeometry(0));
193+ selectCaseWindow->showFullScreen();
194+ removeWisdomToothWindow->close();
195+ return;
196+ default:
197+ glWindow->startTimer();
198+ return;
199 }
200-
201- this->restoreOverrideCursor();
202- // falls down into no
203- case QMessageBox::No:
204- // back to select case menu
205- glWindow->close();
206- selectCaseWindow->setGeometry(QApplication::desktop()->availableGeometry(0));
207- selectCaseWindow->showFullScreen();
208- removeWisdomToothWindow->close();
209- return;
210- default:
211- glWindow->startTimer();
212- return;
213 }
214 }
215
216@@ -463,9 +484,9 @@
217
218 // show the gui screen
219 if(!removeWisdomToothWindow.get())
220- removeWisdomToothWindow.reset(new RemoveWisdomToothWindow(this));
221+ removeWisdomToothWindow.reset(new RemoveWisdomToothWindow(this, playback));
222 else
223- removeWisdomToothWindow->initialize();
224+ removeWisdomToothWindow->initialize(playback);
225
226 volumeModel = static_cast <VolumeModel*> (glWindow->getSceneNode("VM"));
227 loggingNode = static_cast <LoggingNode*> (glWindow->getSceneNode("LN"));
228@@ -474,10 +495,14 @@
229 if(loggingNode)
230 loggingNode->userLoggingPathField->setValue(userLoggingDirectory->path().toStdString());
231
232+ this->isPlayback = false;
233 // set playback data
234 if(playback)
235+ {
236+ this->isPlayback = true;
237 if(volumeModel)
238 volumeModel->setTimeStampFile(playbackFilePath.path().toStdString());
239+ }
240
241 removeWisdomToothWindow->setGeometry(QApplication::desktop()->availableGeometry(0));
242 removeWisdomToothWindow->showFullScreen();
243
244=== modified file 'FsWisdom/ApplicationNode.h'
245--- FsWisdom/ApplicationNode.h 2009-06-03 14:26:23 +0000
246+++ FsWisdom/ApplicationNode.h 2009-06-09 14:25:42 +0000
247@@ -239,6 +239,7 @@
248 LoggingNode* loggingNode;
249
250 QSqlDatabase forsDatabase;
251+ bool isPlayback;
252 };
253
254 }
255
256=== modified file 'FsWisdom/RemoveWisdomToothWindow.cpp'
257--- FsWisdom/RemoveWisdomToothWindow.cpp 2009-06-03 13:57:58 +0000
258+++ FsWisdom/RemoveWisdomToothWindow.cpp 2009-06-09 14:25:42 +0000
259@@ -2,7 +2,7 @@
260
261 using namespace FS;
262
263-RemoveWisdomToothWindow::RemoveWisdomToothWindow(ApplicationNode *applicationNode, QWidget* parent)
264+RemoveWisdomToothWindow::RemoveWisdomToothWindow(ApplicationNode *applicationNode, bool playback, QWidget* parent)
265 : QMainWindow(parent)
266 {
267 this->applicationNode = applicationNode;
268@@ -52,10 +52,10 @@
269 QObject::connect(ui.selectElevatorButton, SIGNAL(clicked ()), this, SLOT(selectElevator ()));
270
271
272- initialize();
273+ initialize(playback);
274 }
275
276-void RemoveWisdomToothWindow::initialize()
277+void RemoveWisdomToothWindow::initialize(bool playback)
278 {
279 materialSegmentationModel = static_cast <MaterialSegmentationModel*> (applicationNode->getSceneNode("SM"));
280 volumeModel = static_cast <VolumeModel*> (applicationNode->getSceneNode("VM"));
281@@ -169,7 +169,7 @@
282
283 updater_label_teethRotationField_2.reset(new Updater_QLabel_SFRotation(ui,ui.teethRotation,ui.teethRadio,teeth->rotation.get(),defaultValues->rotationZoomFactorField.get(),1));
284
285-
286+ this->isPlayback = playback;
287 setupStatistics();
288
289 }
290
291=== modified file 'FsWisdom/RemoveWisdomToothWindow.h'
292--- FsWisdom/RemoveWisdomToothWindow.h 2009-06-03 13:57:58 +0000
293+++ FsWisdom/RemoveWisdomToothWindow.h 2009-06-09 14:25:42 +0000
294@@ -61,10 +61,10 @@
295 Q_OBJECT
296
297 public:
298- RemoveWisdomToothWindow(ApplicationNode *applicationNode, QWidget* parent = 0);
299+ RemoveWisdomToothWindow(ApplicationNode *applicationNode, bool playback, QWidget* parent = 0);
300 ~RemoveWisdomToothWindow();
301
302- void initialize();
303+ void initialize(bool playback);
304
305 void setupStatistics();
306
307@@ -123,6 +123,7 @@
308 Switch* vibrations;
309 StateMachine* stateMachine;
310 LoggingNode* loggingNode;
311+ bool isPlayback;
312
313 // routing between fields and widgets
314
315@@ -203,10 +204,6 @@
316
317 auto_ptr<Updater_QTableWidget> updater_tableWidget_forbiddenSegmentationField;
318 auto_ptr<Updater_QTableWidget> updater_tableWidget_materialSegmentationField;
319-
320-
321-
322-
323 };
324
325 }
326
327=== modified file 'FsWisdom/SelectCaseWindow.cpp'
328--- FsWisdom/SelectCaseWindow.cpp 2009-06-05 09:07:12 +0000
329+++ FsWisdom/SelectCaseWindow.cpp 2009-06-09 14:25:42 +0000
330@@ -43,8 +43,6 @@
331 QObject::connect(ui.caseListWidget, SIGNAL(itemSelectionChanged ()), this, SLOT(updateAnamnesTextWidget()));
332 QObject::connect(ui.caseListWidget, SIGNAL(itemSelectionChanged ()), this, SLOT(updateObjectivesTextWidget()));
333 QObject::connect(ui.caseListWidget, SIGNAL(itemSelectionChanged ()), this, SLOT(updateImageViewer()));
334- QObject::connect(ui.caseListTimestampsWidget, SIGNAL(itemSelectionChanged ()), this, SLOT(getCurrentTimestampForPlayback()));
335-
336
337 //standardOutputToTextEdit.reset(new QDebugStream(std::cout, ui.standardOutputPlainTextEdit,QDir("stdout.txt")));
338 //standardErrorToTextEdit.reset(new QDebugStream(std::cerr, ui.standardErrorPlainTextEdit,QDir("stderr.txt")));
339@@ -156,6 +154,10 @@
340 forsCaseVersionId = query.value(0).toInt();
341 }
342 }
343+ if (isPlayback)
344+ {
345+ this->getCurrentTimestampForPlayback();
346+ }
347 cout<< " the File to be lauched now " << x3dFilePath.path().toStdString()<<endl;
348 applicationNode->launchX3DWithStandardGuiWindow(x3dFilePath, isPlayback, forsCaseVersionId);
349 }
350
351=== modified file 'FsWisdom/SelectCaseWindow.h'
352--- FsWisdom/SelectCaseWindow.h 2009-06-05 09:07:12 +0000
353+++ FsWisdom/SelectCaseWindow.h 2009-06-09 14:25:42 +0000
354@@ -31,6 +31,7 @@
355 ~SelectCaseWindow();
356
357 void initialize();
358+ void getCurrentTimestampForPlayback();
359
360 public slots:
361 /// locates an x3d file to execute
362@@ -53,7 +54,6 @@
363 void updateCaseListTimestampsWidget();
364 void updateAnamnesTextWidget();
365 void updateObjectivesTextWidget();
366- void getCurrentTimestampForPlayback();
367 void updateImageViewer();
368
369
370
371=== modified file 'FsWisdom/SelectCaseWindow.ui'
372--- FsWisdom/SelectCaseWindow.ui 2009-06-08 14:19:45 +0000
373+++ FsWisdom/SelectCaseWindow.ui 2009-06-09 14:25:42 +0000
374@@ -114,7 +114,7 @@
375 <rect>
376 <x>600</x>
377 <y>340</y>
378- <width>201</width>
379+ <width>241</width>
380 <height>18</height>
381 </rect>
382 </property>

Subscribers

People subscribed via source and target branches

to all changes: