16 #include <QVBoxLayout> 18 #include <QPushButton> 19 #include "vtkMNITagPointReader.h" 20 #include "vtkStringArray.h" 21 #include <ctkPluginContext.h> 41 mPatientModelServicePrivate(patientModelService),
42 mViewService(viewService)
44 std::vector<QString> uids;
45 uids.push_back(
"dummyParent1");
46 uids.push_back(
"dummyParent2");
69 this->
readInto(pointMetric, filename);
75 std::vector<DataPtr> retval;
83 reader->SetFileName(filename.toStdString().c_str());
88 int number_of_volumes = reader->GetNumberOfVolumes();
89 QString description(reader->GetComments());
95 vtkStringArray *labels = reader->GetLabelText();
97 for(
int i=0; i< number_of_volumes; ++i)
99 QColor color = getRandomColor();
101 vtkPoints *points = reader->GetPoints(i);
104 unsigned int number_of_points = points->GetNumberOfPoints();
107 for(
int j=0; j < number_of_points; ++j)
109 vtkStdString label = labels->GetValue(j);
110 name = QString::fromStdString(label);
111 if(name.isEmpty() || (name == QString(
" ")) )
112 name = QString::number(j+1);
114 double *point = points->GetPoint(j);
120 Vector3D vector_lps(point[0], point[1], point[2]);
123 point_metric->setCoordinate(vector_lps);
124 point_metric->setSpace(space);
125 point_metric->setColor(color);
127 retval.push_back(data_point_metric);
237 mVolumeUids = volumeUids;
240 QColor MNIReaderWriter::getRandomColor()
242 QStringList colorNames = QColor::colorNames();
243 int random_int = rand() % colorNames.size();
244 QColor color(colorNames[random_int]);
245 if(color == QColor(
"black"))
246 color = getRandomColor();
251 std::vector<QString> MNIReaderWriter::dialogForSelectingVolumesForImportedMNITagFile(
int number_of_volumes, QString description)
253 std::vector<QString> data_uid;
255 QDialog selectVolumeDialog;
256 selectVolumeDialog.setWindowTitle(
"Select volume(s) related to points in MNI Tag Point file.");
258 QVBoxLayout *layout =
new QVBoxLayout();
259 QLabel *description_label =
new QLabel(description);
260 layout->addWidget(description_label);
262 std::map<int, StringPropertySelectImagePtr> selectedImageProperties;
263 for(
int i=0; i < number_of_volumes; ++i)
266 QWidget *widget =
createDataWidget(mViewService, mPatientModelServicePrivate, NULL, image_property);
267 layout->addWidget(widget);
268 selectedImageProperties[i] = image_property;
271 QPushButton *okButton =
new QPushButton(tr(
"Ok"));
272 layout->addWidget(okButton);
273 connect(okButton, &QAbstractButton::clicked, &selectVolumeDialog, &QWidget::close);
274 selectVolumeDialog.setLayout(layout);
275 selectVolumeDialog.exec();
276 for(
int i=0; i < number_of_volumes; ++i)
279 data_uid.push_back(image_property->getValue());
284 bool MNIReaderWriter::validateKnownVolumeUids(
int numberOfVolumesInFile)
const 287 retval &= numberOfVolumesInFile == mVolumeUids.size();
288 for(
int i=0; i<mVolumeUids.size(); ++i)
290 DataPtr data = mPatientModelServicePrivate->getData(mVolumeUids[i]);
DataPtr createData(QString type, QString filename, QString name="") const
void setVolumeUidsRelatedToPointsInMNIPointFile(std::vector< QString > volumeUids)
bool canReadInternal(const QString &type, const QString &filename) const
DataPtr read(const QString &uid, const QString &filename)
csREF
the data reference space (r) using LPS (left-posterior-superior) coordinates.
QWidget * createDataWidget(ViewServicePtr viewService, PatientModelServicePtr patientModelService, QWidget *parent, PropertyPtr data, QGridLayout *gridLayout, int row)
Create a widget capable of displaying the input data.
bool canRead(const QString &type, const QString &filename)
boost::shared_ptr< class Data > DataPtr
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
Identification of a Coordinate system.
void write(DataPtr data, const QString &filename)
boost::shared_ptr< class StringPropertySelectImage > StringPropertySelectImagePtr
Data class that represents a single point.
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
void forceNewlineBeforeEof(QString path)
MNIReaderWriter(PatientModelServicePtr patientModelService, ViewServicePtr viewService)
QString canWriteDataType() const
static QString getTypeName()
bool readInto(DataPtr data, QString path)
static bool checkedRead(vtkSmartPointer< vtkAlgorithm > reader, QString filename)
static StringPropertySelectImagePtr New(PatientModelServicePtr patientModelService)
bool canWrite(const QString &type, const QString &filename) const
QString canReadDataType() const
vtkSmartPointer< class vtkMNITagPointReader > vtkMNITagPointReaderPtr
Namespace for all CustusX production code.
boost::shared_ptr< class PointMetric > PointMetricPtr