47 #include <QGridLayout>
48 #include <QFileDialog>
50 #include <QMessageBox>
69 QLabel *textBrowseButton =
new QLabel(
tr(
"Select only 1 file\nfrom the Image Set*:") );
84 BrowseButtonLayout->
addWidget(textBrowseButton, 0, 0);
119 tr(
"Import a new dataset for the project '%1'\n (*fields are required) and click on 'Finish' to load them:")
120 .arg(
field(
"ProjectName").toString() ) );
131 this,
tr(
"Import Image"),
"",
tr(
"Images (*.png *.bmp *.jpg *.jpeg *tif *.tiff *.mha *.mhd *.img *.lsm)") );
144 std::vector< std::string > vectListMicroscopes =
147 if ( !vectListMicroscopes.empty() )
149 for (
unsigned int i = 0; i < vectListMicroscopes.size(); ++i )
151 ListMicroscopes.
append( vectListMicroscopes[i].c_str() );
155 return ListMicroscopes;
170 float XTileOverlap = 0;
171 float YTileOverlap = 0;
172 float ZTileOverlap = 0;
180 myNewImgSession.
SetField(
"ImagesTimeInterval", TimeInterval);
181 myNewImgSession.
SetField(
"RealPixelDepth", RealPixelDepth);
182 myNewImgSession.
SetField(
"RealPixelHeight", RealPixelHeight);
183 myNewImgSession.
SetField(
"RealPixelWidth", RealPixelWidth);
184 myNewImgSession.
SetField(
"ProjectName", m_ProjectName);
186 myNewImgSession.
SetField(
"CreationDate", CreationDateTime);
187 myNewImgSession.
SetField(
"XImageSize", XImageSize);
188 myNewImgSession.
SetField(
"YImageSize", YImageSize);
189 myNewImgSession.
SetField(
"XTileOverlap", XTileOverlap);
190 myNewImgSession.
SetField(
"YTileOverlap", YTileOverlap);
191 myNewImgSession.
SetField(
"ZTileOverlap", ZTileOverlap);
196 if ( ExistingImgSession == -1 )
198 return AddOnlyOneNewObjectInTable< GoDBImgSessionRow >(DatabaseConnector,
199 "imagingsession", myNewImgSession,
"ImagingSessionID");
214 tr(
"Please make sure that all the required fields (*) are not empty.") );
223 if ( ProjectNameTaken.size() != 0 )
227 tr(
"This name is already taken for an existing Imaging Session.\nPlease select another one.") );
234 msgBox.
setText(
tr(
"Please choose a microscope for your imaging session.") );
243 tr(
"The images you selected are of an old megacapture format, not supported by this database.") );
250 if(!cleanFileToBeImported)
252 return cleanFileToBeImported;
273 if ( DatabaseConnector != 0 )
279 myRecordSetType *RecordSet =
new myRecordSetType;
281 RecordSet->SetTableName(
"image");
286 m_PCoordMin = filelist.get< m_PCoord >().begin()->m_PCoord;
287 m_PCoordMax = filelist.get< m_PCoord >().rbegin()->m_PCoord;
289 m_RCoordMin = filelist.get< m_RCoord >().begin()->m_RCoord;
290 m_RCoordMax = filelist.get< m_RCoord >().rbegin()->m_RCoord;
292 m_CCoordMin = filelist.get< m_CCoord >().begin()->m_CCoord;
293 m_CCoordMax = filelist.get< m_CCoord >().rbegin()->m_CCoord;
295 m_XTileCoordMin = filelist.get< m_XTileCoord >().begin()->m_XTileCoord;
296 m_XTileCoordMax = filelist.get< m_XTileCoord >().rbegin()->m_XTileCoord;
298 m_YTileCoordMin = filelist.get< m_YTileCoord >().begin()->m_YTileCoord;
299 m_YTileCoordMax = filelist.get< m_YTileCoord >().rbegin()->m_YTileCoord;
301 m_ZTileCoordMin = filelist.get< m_ZTileCoord >().begin()->m_ZTileCoord;
302 m_ZTileCoordMax = filelist.get< m_ZTileCoord >().rbegin()->m_ZTileCoord;
304 m_TCoordMin = filelist.get< m_TCoord >().begin()->m_TCoord;
305 m_TCoordMax = filelist.get< m_TCoord >().rbegin()->m_TCoord;
307 m_ZCoordMin = filelist.get< m_ZCoord >().begin()->m_ZCoord;
308 m_ZCoordMax = filelist.get< m_ZCoord >().rbegin()->m_ZCoord;
313 while ( f_it != f_end )
316 field(
"ImgSessionID").toInt() );
317 RecordSet->AddObject(Image);
322 if ( !RecordSet->SaveInDB() )
324 std::cout <<
"The images have not been saved in the DB" << std::endl;
325 std::cout <<
"Debug: In " << __FILE__ <<
", line " << __LINE__;
326 std::cout << std::endl;
331 catch (
const itk::ExceptionObject & e )
333 std::cerr <<
" caught an ITK exception: " << std::endl;
337 catch (
const std::exception & e )
339 std::cerr <<
" caught an std exception: " << std::endl;
340 std::cerr << e.what() << std::endl;
345 std::cerr <<
" caught an unknown exception!" << std::endl;
372 catch (
const itk::ExceptionObject & e )
374 std::cerr <<
" caught an ITK exception: " << std::endl;
378 catch (
const std::exception & e )
380 std::cerr <<
" caught an std exception: " << std::endl;
381 std::cerr << e.what() << std::endl;
384 catch ( std::string & e )
386 std::cerr <<
" caught an exception: " << std::endl;
387 std::cerr << e << std::endl;
392 std::cerr <<
" caught an unknown exception!" << std::endl;
402 int ImagingSessionID)
407 myRecordSetType *RecordSet =
new myRecordSetType;
409 RecordSet->SetTableName(
"channel");
411 std::cout <<
"m_HeaderFileInfo.m_NumberOfChannels: "
419 std::string StringChannelNumber = ConvertToString< int >(i);
420 std::string ChannelName =
"Channel " + StringChannelNumber;
421 std::string ColorName =
"ColorFor";
422 ColorName += ChannelName;
429 myNewColor.
SetField(
"Name", ColorName);
431 myNewColor.
SetField(
"Green", Green);
433 myNewColor.
SetField(
"Alpha", Alpha);
435 int ColorID = myNewColor.
SaveInDB(DatabaseConnector);
440 myNewChannel.
SetField(
"ColorID", ColorID);
441 myNewChannel.
SetField(
"Name", ChannelName);
442 myNewChannel.
SetField(
"ImagingSessionID", ImagingSessionID);
443 myNewChannel.
SetField(
"ChannelNumber", i);
445 RecordSet->AddObject(myNewChannel);
447 RecordSet->SaveInDB();
458 myNewImageCoordMin.
SetField(
"PCoord", It->m_PCoord);
459 myNewImageCoordMin.
SetField(
"RCoord", It->m_RCoord);
460 myNewImageCoordMin.
SetField(
"CCoord", It->m_CCoord);
461 myNewImageCoordMin.
SetField(
"XTileCoord", It->m_XTileCoord);
462 myNewImageCoordMin.
SetField(
"YTileCoord", It->m_YTileCoord);
463 myNewImageCoordMin.
SetField(
"ZTileCoord", It->m_ZTileCoord);
464 myNewImageCoordMin.
SetField(
"XCoord", It->m_XCoord);
465 myNewImageCoordMin.
SetField(
"YCoord", It->m_YCoord);
466 myNewImageCoordMin.
SetField(
"ZCoord", It->m_ZCoord);
467 myNewImageCoordMin.
SetField(
"TCoord", It->m_TCoord);
492 return myNewImageCoordMin.
SaveInDB(DatabaseConnector);
499 int ImagingSessionID,
int ChannelNumber)
501 std::vector< FieldWithValue > Conditions(2);
502 FieldWithValue ImgSession = {
"ImagingSessionID", ConvertToString< int >(ImagingSessionID),
"=" };
503 FieldWithValue Channel = {
"ChannelNumber", ConvertToString< int >(ChannelNumber),
"=" };
504 Conditions[0] = ImgSession;
505 Conditions[1] = Channel;
507 return FindOneID(DatabaseConnector,
"channel",
"channelID", Conditions);
518 myNewImage.
SetField(
"ImagingSessionID", ImagingSessionID);
520 myNewImage.
SetField(
"Filename", It->m_Filename);
525 ImagingSessionID, It->m_Channel);
528 std::cout <<
"The channel doesn't exist in the DB" << std::endl;
529 std::cout <<
"Debug: In " << __FILE__ <<
", line " << __LINE__;
530 std::cout << std::endl;
534 myNewImage.
SetField(
"ChannelID", channel);
542 vtkMySQLDatabase *DatabaseConnector,
int ImagingSessionID)
544 std::string imgsessionid = ConvertToString< int >(ImagingSessionID);
567 ConvertToString< int >(CoordIDMax),
589 ConvertToString< int >(CoordIDMin),
613 bool cleanFileToBeImported =
615 if(!cleanFileToBeImported)
618 msgBox.
setText(
tr(
"The images you try to import are corrupted.") );
626 setField(
"ImgSessionID", ImgSessionID);
627 if ( ImgSessionID != -1 )
647 tr(
"The images imported already belongs to an existing Imaging Session.") );
686 field(
"User").toString().toStdString(),
687 field(
"Password").toString().toStdString() );
688 CreateMicroscopePage->
show();
void CreateImgSessionCoord(vtkMySQLDatabase *DatabaseConnector, int ImagingSessionID)
create into the DB the coordinates corresponding to the CoordID Min and Max for the Imaging Session a...
std::string toStdString() const
GoDBCoordinateRow m_ImgSessionCoordMax
in the QTextEdit class, there is no method to have a restriction on the number of characters the user...
QStringList GetListMicroscopes()
get the list of the existing microscopes registered in the DB
QTextEditChild * lineDescription
unsigned int m_XTileCoordMin
bool SaveInfoInDatabase()
manages a map with keys matching fields of the gofiguredatabase ImgSession table and values of the ma...
void setSubTitle(const QString &subTitle)
void setFile(const QString &file)
bool CloseDatabaseConnection(vtkMySQLDatabase *DatabaseConnector)
return true if the connection has been closed, false if the connection was already closed ...
GoDBCoordinateRow m_ImgSessionCoordMin
QPushButton * AddMicroscopeButton
vtkMySQLDatabase * OpenDatabaseConnection(std::string ServerName, std::string login, std::string Password, std::string DBName)
QPushButton * BrowseButton
QString toPlainText() const
manages a map with keys matching fields of the gofiguredatabase Coordinate table and values of the ma...
QLabel * textNewImgSessionName
QGoCreateImgSessionPage(QWidget *parent=0)
QString tr(const char *sourceText, const char *disambiguation, int n)
bool ImportInfoFromMegacapture(QString newfilename)
fill m_importFileInfoList from the filenames of the images and m_HeaderFileInfo from the header file ...
void setField(const QString &name, const QVariant &value)
void UpdateValueInDB(vtkMySQLDatabase *DatabaseConnector, std::string iTableName, std::string iColumnName, std::string iNewValue, std::string iField, std::vector< unsigned int > iVectIDs)
GoFigureFileInfoHelperMultiIndexContainer::iterator MultiIndexContainerIteratorType
this class manages the map with the keys matching the fields of the Color gofiguredatabase table and ...
int SaveInDB(vtkMySQLDatabase *DatabaseConnector)
save the coordinate in the database and return the ID of the new created coordinate or the ID of the ...
void setBold(bool enable)
QLabel * textChoiceMicroscope
QComboBox * ChoiceMicroscope
virtual int SaveInDB(vtkMySQLDatabase *iDatabaseConnector)
Pure Virtual :check if the entity already exists in the DB, if yes, return the existing ID...
void append(const T &value)
std::string GetMegaCaptureHeaderFilename()
QLineEdit * lineNewImgSessionName
std::vector< std::string > ListAllValuesForOneColumn(vtkMySQLDatabase *DatabaseConnector, const std::string &ColumnName, const std::string &TableName, std::string OrderByColumnName)
SELECT ColumnName from TableName ORDER BY OrderbyColumnName.
unsigned int m_ZTileCoordMax
GoDBImageRow CreateImage(vtkMySQLDatabase *DatabaseConnector, MultiIndexContainerIteratorType It, int ImagingSessionID)
return a GoDBImageRow filled with all the data corresponding
GoFigureFileInfoHelperMultiIndexContainer GetMultiIndexFileContainer()
void setText(const QString &text)
int CreateImgSession(vtkMySQLDatabase *DatabaseConnector)
create a new imaging session into the DB with the information filled by the user and collected from t...
unsigned int m_XTileCoordMax
std::vector< std::string > ListSpecificValuesForOneColumn(vtkMySQLDatabase *iDatabaseConnector, const std::string &TableName, const std::string &ColumnName, const std::string &field, const std::string &value, bool ExcludeZero)
SELECT ColumnName FROM TableName WHERE field = value and ColumnName <> 0 (if excludezero) ...
int FindOneID(vtkMySQLDatabase *DatabaseConnector, const std::string &TableName, const std::string &ColumnName, const std::string &field, const std::string &value)
SELECT ColumnName FROM TableName WHERE field = value.
manages a map with keys matching fields of the gofiguredatabase Image table and values of the map mat...
void SetConnector(vtkMySQLDatabase *iDatabaseConnector)
unsigned int m_YTileCoordMax
MegaCaptureHeaderReader m_HeaderFileInfo
QVariant field(const QString &name) const
void ImportImages(vtkMySQLDatabase *DatabaseConnector)
create the imaging session, all the channels into the DB, then the images selected by the user and at...
void SetField(const std::string &key, const T &value)
convert the value into a string and assign it to the key in the map
void setColumnStretch(int column, int stretch)
itk::MegaCaptureImport::Pointer m_importFileInfoList
static bool IsNewMegaCapture(const std::string &iFilename)
return true if the filename is of new megacapture format, false if it is the old one ...
void CreateChannels(vtkMySQLDatabase *DatabaseConnector, int ImagingSessionID)
create the channels and their corresponding colors in the database, from the data gotten from the hea...
manages a map with keys matching fields of the gofiguredatabase Channel table and values of the map m...
int CreateImageCoordMin(vtkMySQLDatabase *DatabaseConnector, MultiIndexContainerIteratorType It)
create the coordinate CoordMin in the DB, check and update if its values are less than the other Coor...
unsigned int m_ZTileCoordMin
void addItems(const QStringList &texts)
unsigned int m_YTileCoordMin
QString getOpenFileName(QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, QFlags< QFileDialog::Option > options)
int DoesThisImagingSessionExist(vtkMySQLDatabase *DatabaseConnector)
return the ImgSessionID of the imaging session with the same date+time of creation and microscope alr...
void SetDatabaseVariables(std::string iUser, std::string iPassword)
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
void setText(const QString &text)
vtkMySQLDatabase * m_DatabaseConnector
int FindChannelIDForImage(vtkMySQLDatabase *DatabaseConnector, int ImagingSessionID, int ChannelNumber)
return the ChannelID from the DB corresponding to the imaging session and to the channel number given...
QByteArray toAscii() const
void UpdateListMicroscopes()
void addLayout(QLayout *layout, int stretch)
~QGoCreateImgSessionPage()