34 #ifndef __QGoPrintDatabase_h
35 #define __QGoPrintDatabase_h
37 #include <QDockWidget>
38 #include <QTableWidget>
41 #include <QStackedWidget>
42 #include "MegaVTK2Configure.h"
45 #include "vtkMySQLDatabase.h"
46 #include "vtkPolyData.h"
51 #include "QGoGUILibConfigure.h"
93 void SetDatabaseVariables(
94 const std::string & iNameDB,
const std::string & iServer,
95 const std::string & iUser,
const std::string & iPassword,
96 const unsigned int & iImgSessionID,
const std::string & iImgSessionName);
101 void FillTableFromDatabase(
const unsigned int& iTreshold);
104 std::vector< ContourMeshStructure > GetContoursForAGivenTimepoint(
105 unsigned int iTimePoint);
108 std::vector< ContourMeshStructure > GetMeshesForAGivenTimepoint(
109 unsigned int iTimePoint);
117 void SaveContoursFromVisuInDB(
unsigned int iXCoordMin,
118 unsigned int iYCoordMin,
unsigned int iZCoordMin,
unsigned int iTCoord,
119 unsigned int iXCoordMax,
unsigned int iYCoordMax,
unsigned int iZCoordMax,
120 vtkPolyData *iContourNodes);
130 void SaveMeshFromVisuInDB(
unsigned int iXCoordMin,
131 unsigned int iYCoordMin,
132 unsigned int iZCoordMin,
133 unsigned int iXCoordMax,
134 unsigned int iYCoordMax,
135 unsigned int iZCoordMax,
137 vtkPolyData *iMeshNodes,
153 unsigned int SaveNewContourForMeshToContours(
unsigned int iXCoordMin,
154 unsigned int iYCoordMin,
155 unsigned int iZCoordMin,
156 unsigned int iXCoordMax,
157 unsigned int iYCoordMax,
158 unsigned int iZCoordMax,
159 vtkPolyData *iTraceNodes);
161 void AddBookmark(
int iXCoord,
int iYCoord,
162 int iZCoord,
int iTCoord);
166 std::string InWhichTableAreWe();
174 bool IsDatabaseUsed();
182 void ImportContours();
196 std::vector<int> ImportTracks();
205 iMeshAttributes,
unsigned int iMeshID);
214 iTrackAttributes,
unsigned int iTrackID);
227 void SetTraceNameForTableWidget(std::string iTraceName);
231 void InitializeTheComboboxesNotTraceRelated();
271 bool NeedTraceSettingsToolBarVisible();
279 std::list<unsigned int> UpdateTableWidgetAndContainersForGivenTimePoint(
280 const unsigned int& iNewTimePoint);
282 std::list<unsigned int> GetVisibleTimePoints();
284 int GetNumberOfElementForTraceAndTimePoint(std::string iTrace,
int iTimePoint);
287 void DeleteBookmarks();
291 void ExportContours();
295 void UpdateSelectedTimePoint(
int iTimePoint);
297 void SaveNewMeshForMeshToContours(
int iNumberOfContours);
302 void DBVariablesSet();
304 void TraceToReEdit(
unsigned int);
306 void OpenBookmarksToUpdate();
308 void NewMeshToGenerate(std::list< unsigned int > ListContourIDs,
int iNewMeshID);
314 void NeedToGoToTheLocation(
int XCoord,
int YCoord,
int ZCoord,
int TCoord);
316 void NeedToGoToTheRealLocation(
double XCoord,
double YCoord,
double ZCoord,
int TCoord);
318 void PrintMessage(
QString iMessage,
int iTimeOut = 0);
352 void OpenDBConnection();
360 void SetConnectionsBetweenTheInstancesOfTraceSettings();
364 void SetContoursManager();
369 void SetMeshesManager();
374 void SetTracksManager();
379 void SetLineagesManager();
395 void SetTSListCellTypes(std::string iCellTypeToSelect =
"");
402 void SetTSListCellTypesWithPreviousSelectedOne();
410 void SetTSListSubCellTypes(std::string iSubCellTypeToSelect =
"");
417 void SetTSListSubCellTypesWithPreviousSelectedOne();
425 void SetTSListColors(std::string iColorToSelect =
"");
432 void SetTSListColorsWithPreviousSelectedOne();
442 std::list< ItemColorComboboxData > GetListCollectionIDFromDB(
443 vtkMySQLDatabase *iDatabaseConnector, std::string & ioIDToSelect);
450 void SetTracesManager();
457 void GetContentAndDisplayAllTracesInfo(vtkMySQLDatabase *iDatabaseConnector);
459 void GetContentAndDisplayAllTracesInfoFor3TPs(vtkMySQLDatabase *iDatabaseConnector);
461 void RemoveTracesFromListTimePoints(
462 vtkMySQLDatabase *iDatabaseConnector, std::list<unsigned int> iListTimePoints);
491 template<
typename T >
492 void SetTheColorForTheRow(T & ioRow,
QColor iColor)
494 ioRow.SetField(
"Red", iColor.
red() );
495 ioRow.SetField(
"Green", iColor.
green() );
496 ioRow.SetField(
"Blue", iColor.
blue() );
497 ioRow.SetField(
"Alpha", iColor.
alpha() );
508 template<
typename TTrace,
typename TCollection >
509 void ChangeTraceColor(TTrace *iTraceManager,
510 TCollection *iCollectionOfManager)
512 this->OpenDBConnection();
515 std::list< unsigned int > ListCollectionOfIDsToUpdate =
516 iTraceManager->UpdateTheTracesColor(this->m_DatabaseConnector);
517 iCollectionOfManager->DisplayInfoForExistingTraces(this->m_DatabaseConnector,
518 ListCollectionOfIDsToUpdate);
519 this->CloseDBConnection();
535 template<
typename TTrace,
typename TCollection,
typename TCollectionOf >
536 void DeleteCheckedTraces(TTrace *iTraceManager,
537 TCollection *iCollectionManager, TCollectionOf *iCollectionOfManager,
538 bool lineage =
false)
541 std::list< unsigned int > ListTracesToDelete =
542 iTraceManager->GetListHighlightedIDs();
543 std::list<unsigned int> ListCollectionsIDs =
544 this->UpdateCollectionDataForTracesToBeDeleted<TTrace, TCollectionOf>
545 (iTraceManager, iCollectionOfManager, ListTracesToDelete);
546 this->OpenDBConnection();
547 iTraceManager->DeleteCheckedTraces(this->m_DatabaseConnector);
549 if ( !ListCollectionsIDs.empty() || !lineage )
551 this->OpenDBConnection();
552 iCollectionManager->UpdateBoundingBoxes(this->m_DatabaseConnector, ListCollectionsIDs);
554 this->CloseDBConnection();
569 template<
typename TTrace,
typename TCollection,
typename TCollectionOf >
570 void DeleteListTraces(TTrace *iTraceManager,
571 TCollection *iCollectionManager, TCollectionOf *iCollectionOfManager,
572 std::list<unsigned int> iListTracesToDelete,
573 bool lineage =
false)
575 std::list<unsigned int> ListCollectionsIDs =
576 this->UpdateCollectionDataForTracesToBeDeleted<TTrace, TCollectionOf>
577 (iTraceManager, iCollectionOfManager, iListTracesToDelete);
578 this->OpenDBConnection();
579 iTraceManager->DeleteListTraces(this->m_DatabaseConnector, iListTracesToDelete);
581 if ( !ListCollectionsIDs.empty() || !lineage )
583 iCollectionManager->UpdateBoundingBoxes(this->m_DatabaseConnector, ListCollectionsIDs);
585 this->CloseDBConnection();
595 template<
typename TTrace,
typename TCollectionOf >
596 std::list<unsigned int> UpdateCollectionDataForTracesToBeDeleted(TTrace *iTraceManager,
597 TCollectionOf *iCollectionOfManager,
598 std::list<unsigned int> iListTracesToDelete)
600 this->OpenDBConnection();
602 std::list< unsigned int > ListCollectionsIDs =
603 iTraceManager->GetListCollectionIDs(this->m_DatabaseConnector, iListTracesToDelete);
604 std::list< unsigned int > ListTracesAsCollectionOf =
605 iTraceManager->GetListTracesIDsFromThisCollectionOf(this->m_DatabaseConnector,
606 iListTracesToDelete);
607 if ( !ListTracesAsCollectionOf.empty() )
609 iCollectionOfManager->UpdateCollectionID(this->m_DatabaseConnector,
610 ListTracesAsCollectionOf, 0);
612 this->CloseDBConnection();
613 return ListCollectionsIDs;
626 template<
typename TTrace,
typename TCollection >
627 void AddCheckedTracesToCollection(
628 TTrace *iTraceManager,
629 TCollection *iCollectionManager,
unsigned int iCollectionID,
630 std::list< unsigned int > iListCheckedTraces)
632 this->OpenDBConnection();
634 std::list< unsigned int > ListCollectionIDsToUpdate =
635 iTraceManager->GetListCollectionIDs(this->m_DatabaseConnector,
638 iTraceManager->UpdateCollectionID(this->m_DatabaseConnector,
639 iListCheckedTraces, iCollectionID);
641 if (iCollectionID != 0)
643 ListCollectionIDsToUpdate.push_back(iCollectionID);
645 iCollectionManager->UpdateBoundingBoxes(this->m_DatabaseConnector,
646 ListCollectionIDsToUpdate);
647 this->CloseDBConnection();
650 void UpdateSelectedCollectionForTableWidget(std::string iTableName);
656 void CreateContextMenu(
const QPoint & iPos);
662 void ShowHideTraceSettingsFromContextMenu(
bool isVisible);
667 void TheTraceHasChanged(
int iIndex);
676 void SetTSListCollectionID();
681 void PassDBConnectionToContoursManager();
686 void PassDBConnectionToMeshesManager();
691 void PassDBConnectionToTracksManager();
696 void PassDBConnectionToLineagesManager();
698 void CloseDBConnection();
703 void ChangeMeshColor();
709 void ChangeTrackColor();
715 void ChangeLineageColor();
721 void DeleteCheckedContours();
727 void DeleteCheckedMeshes();
733 void DeleteCheckedTracks();
739 void DeleteCheckedLineages();
746 void CreateNewTrackFromListMeshes(std::list< unsigned int > iListMeshes);
751 void CreateNewTrackFromListMeshes(
752 std::list<std::list<unsigned int> > iListsCheckedMeshes);
761 void CreateNewMeshFromCheckedContours(std::list< unsigned int > iListCheckedContours);
770 void CreateNewLineageFromTracks(std::list< unsigned int > iListCheckedTracks,
771 unsigned int iTrackIDRoot, std::list<unsigned int> iLineagesToDelete);
779 void AddCheckedContoursToSelectedMesh(std::list< unsigned int > iListCheckedContours);
787 void AddCheckedMeshesToSelectedTrack(std::list< unsigned int > iListCheckedMeshes);
797 void AddCheckedTracksToSelectedLineage(
798 std::list<unsigned int> iListDaughters,
unsigned int iLineageID,
799 std::list<unsigned int> iListLineagesToDelete);
805 void ReEditTrace(
unsigned int iTraceID);
813 void PassMeshesInfoForImportedTrack(
unsigned int iTrackID);
821 void SplitTheTrack(
unsigned int iTrackID, std::list<unsigned int> iListMeshIDs);
830 void SplitMergeTracksWithWidget(std::list<unsigned int> iTrackIDs);
839 void AddListMeshesToATrack(std::list< unsigned int > iListMeshes,
unsigned int iTrackID);
844 void AddListMeshesToATrack(
845 std::map<
unsigned int, std::list<unsigned int> > iListMeshesWithTracks);
853 void SaveNewCollectionFromTraceWidgetInDBAndTW();
860 void AddNewCellType();
867 void AddNewSubCellType();
882 void DeleteCellType();
890 void DeleteSubCellType();