39 mAcquisitionService(acquisitionService),
44 "Select tracker data",
"", QStringList(),
47 connect(mSessionSelector.get(), &
StringProperty::changed,
this, &SelectRecordSession::showSelectedRecordingInView);
49 this->recordedSessionsChanged();
50 this->updateHelpText();
60 if (tool==mToolOverride)
65 this->showSelectedRecordingInView();
68 void SelectRecordSession::recordedSessionsChanged()
70 std::vector<RecordSessionPtr> sessions = mAcquisitionService->getSessions();
72 std::map<QString, QString> names;
73 for(
unsigned i=0; i<sessions.size(); ++i)
75 QString uid = sessions[i]->getUid();
77 names[uid] = sessions[i]->getHumanDescription();
82 mSessionSelector->setValueRange(uids);
83 mSessionSelector->setDisplayNames(names);
85 if(mSessionSelector->getValue().isEmpty() && !uids.isEmpty())
86 mSessionSelector->setValue(uids.last());
88 this->showSelectedRecordingInView();
91 void SelectRecordSession::warnIfNoTrackingDataInSession()
97 CX_LOG_WARNING() << QString(
"Could not find any tracking data for any loaded tools in session [%2]. ")
98 .arg(session.get() ? session->getHumanDescription() :
"NULL");
104 QString uid = mSessionSelector->getValue();
106 return mAcquisitionService->getSession(uid);
117 return trackerRecordedData_prMt;
123 return mToolOverride;
128 ToolPtr tool = this->findToolContainingMostDataForSession(tools, session);
135 this->showSelectedRecordingInView();
138 ToolPtr SelectRecordSession::findToolContainingMostDataForSession(std::map<QString, ToolPtr> tools,
RecordSessionPtr session)
140 std::map<int,ToolPtr> tooldata;
142 for (TrackingService::ToolMap::iterator i=tools.begin(); i!=tools.end(); ++i)
147 tooldata[trackerRecordedData_prMt.size()] = i->second;
150 if (!tooldata.empty() && (tooldata.rbegin()->first!=0))
151 return tooldata.rbegin()->second;
156 void SelectRecordSession::updateHelpText()
159 QString toolname = tool ? tool->getName() :
"<none>";
160 mSessionSelector->setHelp(QString(
"Select tracker data, current data uses tool %2")
166 return mServices->view()->get3DReps(0, 0)->findFirst<
ToolRep3D>(tool);
169 void SelectRecordSession::showSelectedRecordingInView()
175 this->warnIfNoTrackingDataInSession();
178 if (trackerRecordedData_prMt.empty())
181 mCurrentTracedTool = this->
getTool();
182 this->updateHelpText();
184 ToolRep3DPtr activeRep3D = this->getToolRepIn3DView(mCurrentTracedTool);
188 if(!trackerRecordedData_prMt.empty())
190 activeRep3D->getTracer()->clear();
191 activeRep3D->getTracer()->setColor(QColor(
"green"));
192 activeRep3D->getTracer()->addManyPositions(trackerRecordedData_prMt);
196 activeRep3D->getTracer()->clear();
200 void SelectRecordSession::clearTracer()
202 ToolRep3DPtr activeRep3D = this->getToolRepIn3DView(mCurrentTracedTool);
206 activeRep3D->getTracer()->clear();
209 mCurrentTracedTool.reset();
SelectRecordSession(XmlOptionFile options, AcquisitionServicePtr acquisitionService, VisServicesPtr services)
boost::shared_ptr< class AcquisitionService > AcquisitionServicePtr
boost::shared_ptr< class VisServices > VisServicesPtr
QDomElement getElement()
return the current element
static TimedTransformMap getToolHistory_prMt(ToolPtr tool, RecordSessionPtr session, bool verbose)
void setTool(ToolPtr tool)
boost::shared_ptr< class RecordSession > RecordSessionPtr
TimedTransformMap getRecordedTrackerData_prMt()
void changed()
emit when the underlying data value is changed: The user interface will be updated.
static StringPropertyPtr initialize(const QString &uid, QString name, QString help, QString value, QStringList range, QDomNode root=QDomNode())
virtual ~SelectRecordSession()
std::map< QString, ToolPtr > ToolMap
void recordedSessionsChanged()
boost::shared_ptr< class ToolRep3D > ToolRep3DPtr
Helper class for xml files used to store ssc/cx data.
std::map< double, Transform3D > TimedTransformMap
Namespace for all CustusX production code.
boost::shared_ptr< class Tool > ToolPtr