GOFIGURE2  0.9.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
GoDBTraceRow.h
Go to the documentation of this file.
1 /*=========================================================================
2  Authors: The GoFigure Dev. Team.
3  at Megason Lab, Systems biology, Harvard Medical school, 2009-11
4 
5  Copyright (c) 2009-11, President and Fellows of Harvard College.
6  All rights reserved.
7 
8  Redistribution and use in source and binary forms, with or without
9  modification, are permitted provided that the following conditions are met:
10 
11  Redistributions of source code must retain the above copyright notice,
12  this list of conditions and the following disclaimer.
13  Redistributions in binary form must reproduce the above copyright notice,
14  this list of conditions and the following disclaimer in the documentation
15  and/or other materials provided with the distribution.
16  Neither the name of the President and Fellows of Harvard College
17  nor the names of its contributors may be used to endorse or promote
18  products derived from this software without specific prior written
19  permission.
20 
21  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
23  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
25  BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
26  OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
27  OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
28  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
30  OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 
33 =========================================================================*/
34 #ifndef __GoDBTraceRow_h
35 #define __GoDBTraceRow_h
36 
37 #include "GoDBCoordinateRow.h"
38 #include "GoDBRecordSetHelper.h"
39 #include "GoDBRecordSet.h"
40 
41 #include "vtkSmartPointer.h"
42 #include "vtkPolyData.h"
43 #include "vtkMySQLDatabase.h"
44 
50 class QGOIO_EXPORT GoDBTraceRow:public GoDBRow
51 {
52 public:
53  GoDBTraceRow();
54 
64  GoDBTraceRow(vtkMySQLDatabase *DatabaseConnector, vtkPolyData *TraceVisu,
65  GoDBCoordinateRow Min, GoDBCoordinateRow Max, unsigned int ImgSessionID);
66 
67  //GoDBTraceRow(vtkMySQLDatabase *DatabaseConnector, std::string TraceVisu,
68  // GoDBCoordinateRow Min, GoDBCoordinateRow Max, unsigned int ImgSessionID);
69 
70  //GoDBTraceRow(unsigned int ImgSessionID);
71 
72  //GoDBTraceRow(unsigned int iExistingID,vtkMySQLDatabase *iDatabaseConnector);
73 
75  {}
76 
83  int DoesThisBoundingBoxExist(vtkMySQLDatabase *DatabaseConnector);
84 
85 
96  void SetColor(unsigned int Red, unsigned int Green, unsigned int Blue,
97  unsigned int Alpha, std::string ColorName, vtkMySQLDatabase *DatabaseConnector);
98 
103  std::string GetCollectionIDName();
104 
109  std::string GetCollectionName();
110 
120  void SetTheBoundingBox(vtkMySQLDatabase *iDatabaseConnector,
122 
127  void SetCollectionID(unsigned int iCollectionID);
128 
132  bool SetValuesForSpecificID(int ID, vtkMySQLDatabase *iDatabaseConnector);
133 
140  virtual int SaveInDB(vtkMySQLDatabase *DatabaseConnector) = 0;
141 
142 protected:
143 
144  virtual void InitializeMap();
145 
150  // void CreateBoundingBox(vtkMySQLDatabase* DatabaseConnector,
151  // GoDBCoordinateRow Min,
152  // GoDBCoordinateRow Max);
153 
154  std::string m_CollectionIDName;
155  std::string m_CollectionName;
156 
161  void SetImgSessionID(unsigned int iImgSessionID);
162 
171  template< typename T >
172  int SaveInDBTemplate(vtkMySQLDatabase *iDatabaseConnector, T* iTrace)
173  {
174  int SavedTraceID;
175 
176  //in case the ID is different from 0, this means the values have been
177  //updated for this trace, so we update it in the database:
178  if ( this->m_MapRow[this->m_TableIDName] != "0" )
179  {
180  SavedTraceID = UpdateOneNewObjectInTable< T >(iDatabaseConnector,
181  iTrace);
182  }
183  else
184  {
185  SavedTraceID = AddOnlyOneNewObjectInTable< T >(iDatabaseConnector,
186  this->m_TableName, iTrace, this->m_TableIDName);
187  this->SetField(this->m_TableIDName, SavedTraceID);
188  }
189  return SavedTraceID;
190  }
191 
192  template< typename T >
193  void SetTheDataFromTheVisuTemplate(vtkMySQLDatabase *DatabaseConnector,
194  vtkPolyData *TraceVisu,
195  GoDBCoordinateRow iCoordMin,
196  GoDBCoordinateRow iCoordMax)
197  {
198  this->SetTheBoundingBox(DatabaseConnector, iCoordMin, iCoordMax);
199 
200  vtkSmartPointer< T > convert =
201  vtkSmartPointer< T >::New();
202  std::string PointsString = convert->GetMySQLText(TraceVisu);
203 
204  this->SetField("Points", PointsString);
205 
206  if ( this->DoesThisBoundingBoxExist(DatabaseConnector) != -1)
207  {
208  std::cout << "The bounding box already exists for this mesh" << std::endl;
209  }
210  }
211 };
212 #endif
abstract class to be inherited by Contour,Mesh,Track and GoDBLineageRow
Definition: GoDBTraceRow.h:50
abstract class manages a map with keys matching fields of a gofiguredatabase table and values of the ...
Definition: GoDBRow.h:55
void SetTheDataFromTheVisuTemplate(vtkMySQLDatabase *DatabaseConnector, vtkPolyData *TraceVisu, GoDBCoordinateRow iCoordMin, GoDBCoordinateRow iCoordMax)
Definition: GoDBTraceRow.h:193
std::string m_TableIDName
Definition: GoDBRow.h:225
manages a map with keys matching fields of the gofiguredatabase Coordinate table and values of the ma...
virtual bool SetValuesForSpecificID(int ID, vtkMySQLDatabase *iDatabaseConnector)
get the data from the database corresponding to the specific ID and put them in the map ...
Definition: GoDBRow.cxx:209
std::string m_TableName
Definition: GoDBRow.h:224
std::string m_CollectionIDName
check in the database if the Coordinate Min adn Max already exists, if yes fill the map[&quot;CoordIDMin&quot;]...
Definition: GoDBTraceRow.h:154
virtual void InitializeMap()=0
virtual pure. initialize all the values of the map
void SetField(const std::string &key, const T &value)
convert the value into a string and assign it to the key in the map
Definition: GoDBRow.h:73
std::string m_CollectionName
Definition: GoDBTraceRow.h:155
int SaveInDBTemplate(vtkMySQLDatabase *iDatabaseConnector, T *iTrace)
save the row in the database if the TraceID is set to &quot;0&quot;, update the existing traceRow if the TraceI...
Definition: GoDBTraceRow.h:172